Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Validating dates

Avatar

Level 7

Hello - I have a few date fields with validations to MM/DD/YYYY and when users enter another format it only warns them. Is there a way to stop the user from submitting (for example: in Workspace), as it stalls the following script since it doesn't get the desired pattern.

Aditya

0 Replies

Avatar

Level 4

Hi Aditya,

In addition to warning the user that the date is in the wrong format, you could clear the field (e.g. this.rawValue = ""). Then on your submit button you could do a check to see if the date fields are empty. If they are, alert the user else submit the form. Example:

if (dateField.rawValue == "") {

    // tell user to enter a valid date

}

else {

    // submit the form

}