Skip to content

Commit

Permalink
fix validateion
Browse files Browse the repository at this point in the history
  • Loading branch information
enejb committed Feb 8, 2025
1 parent 8c3e1a7 commit 90160d4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions projects/packages/forms/src/contact-form/js/accessible-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,15 @@ const isDateFieldValid = input => {
const format = input.getAttribute( 'data-format' );
const value = input.value;

if ( value && format && validateDate( value, format ) ) {
input.setCustomValidity( '' );
return true;
if ( value && format ) {
if ( validateDate( value, format ) ) {
input.setCustomValidity( '' );
return true;
}
input.setCustomValidity( 'Invalid date' );
return false;
}
input.setCustomValidity( L10N.invalidDate );
return false;
return true;
};

/**
Expand Down

0 comments on commit 90160d4

Please sign in to comment.