- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2016 04:53 AM
Need a validation scripts to validate Email field. Field should validate (@ and .)
if somebody attempts to enter the email address without @ and .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2016 05:05 AM
There is a built in method:
if(oldValue != newValue){
g_form.hideFieldMsg('email', true);
if (!isEmailValid(newValue)) {
g_form.showFieldMsg('email', newValue + " is an invalid email, please re-enter email in correct format.",'error');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 11:31 PM
If we want to validate that field on list view, How can we do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2016 09:10 AM
Thanks for this Mike! Also, just so people don't stall out like I did.
g_form.showFieldMsg('email', newValue + " is an invalid email, please re-enter email in correct format.",'error');
The 'email' portion needs to be the FIELD_NAME that you are showing the error.
Good stuff!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2016 06:13 AM
Hi Anup,
Please use the below code!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
//Validate email address
var str = newValue;
var n = str.indexOf("@");
var n1 = str.indexOf(".");
if (n == -1 || n1 == -1) {
alert('Please enter the valid email address!');
}
}
this is the simple script to validate the value of your email address to see '@' and Period('.') strings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2016 06:46 AM
Thanks jee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2016 05:20 AM
I was able to locate the actual code behind the ServiceNow isEmailValid() function. I detailed it here: https://community.servicenow.com/thread/237846#1006764