- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:37 AM
Hi Guys,
I have a email address field within a Catalog item.
I have created a an onChange catalog client script which checks if the email field is valid syntax and if not throws an error message at the top of the form.
Now that all works fine, but I want to either make the submit button greyed out / unavailable or the field to be kept mandatory until the client script conditions are met,
Because as it stands, users can enter an invalid email address syntax and still submit it!
Below is my code:
Many thanks,
Usmaan.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:51 AM
Hi,
Try onSubmit client script.
and add return false; in if condition after error message.
Thanks,
Dhananjay.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:40 AM
Just after
g_form.addErrorMessage('...');
add
return false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:50 AM
Hi Jaspal,
Thank you. I added return false; as suggested above but it still allows the form to be submitted with invalid email address.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:51 AM
Hi,
Try onSubmit client script.
and add return false; in if condition after error message.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 04:53 AM
Hi,
please move the validation to onSubmit that is the only option
It is not recommended to grey out that submit button
inside the if(){
return false; // to stop form submission
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader