Validation required for email field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 06:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 06:15 PM
Hello pramn,
What kind of validation are you needing to do against the email field? Clearer requirements will help provide a more accurate answer.
Please mark my answer as correct/helpful if it has helped you.
Thanks,
Logan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 07:13 PM
Hello,
Unfortunately, you didn't provide any information as to how you're wanting to validate the email, but it would be recommended to use an email field/variable such as:
Email variable: https://docs.servicenow.com/bundle/rome-servicenow-platform/page/product/service-catalog-management/...
Or for email field, you can use onChange client script on the Email field with script such as:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '')
return;
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email.toLowerCase());
}
if (!(validateEmail(newValue))) {
alert('Please provide a valid email address');
g_form.setValue('error_checkbox', true);
}
}
The above is just an example. Change error_checkbox to the name of your error checkbox field name.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 09:02 PM
Actually clients looking for Script include ... honestly i am new with it .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 08:28 PM
Hi
I have tried implementing the solution suggested by
There are 3 ways you can validate the email
Type 1: Email variable type - Below is how it will look, but setting the Error checkbox value might not be possible this way
Type 2: A single line text field using the oob validation regex from the Type Specifications tab. This validates using the defined Question regular Expression validation as seen below. Setting the Error checkbox value might not be possible this way
Type 3: Using a client script to validate using a regex an set the Error Checkbox. upon invalid email address, throws an alert and sets the checkbox after clicking Ok.
Please mark reply as Helpful/Correct, if applicable. Thanks!