- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:20 AM
Hello All,
I am trying to write a On Change script to validate if Date entered manually in a Date field is in Good Format or not. If it is not in 'YYYY-MM-DD' Format, field should auto clear.
Can anyone suggest me any script for achieving this.
Thanks & Regards,
S.Swaroop.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:34 AM - edited 07-26-2023 07:46 AM
You can use regex to look for that format, then if it doesn't match clear the field and give an error message stating the format needed. Use the link below to help with the regex pattern needed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:34 AM - edited 07-26-2023 07:46 AM
You can use regex to look for that format, then if it doesn't match clear the field and give an error message stating the format needed. Use the link below to help with the regex pattern needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:54 AM
Hello Zach,
It worked. Thank You 🙂
Thanks & Regards,
S.Swaroop.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:55 AM
Awesome! Glad I could help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:47 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == oldValue) {
return;
}
if (getDateFromFormat(newValue, 'YYYY-MM-DD') == 0) {
g_form.hideErrorBox('pstart_date'); //user your field name
g_form.showErrorBox('pstart_date', 'Date is invalid');
}
else {
g_form.clearValue('pstart_date');
}
}