- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 02:43 PM
Hello all,
I need to come up with an email validation to only take the domain @calstate.edu. I found a great post in the community that excludes gmail and yahoo, but I'd think it would be easier to have a script that specified email should include @calstate.edu instead of continually stating yahoo, gmail, outlook, msn, etc. are all excluded.
Kind of got started using the following post found at: https://community.servicenow.com/community?id=community_question&sys_id=bd748f69dbd8dbc01dcaf3231f96...
Any help is greatly appreciated!
Thanks,
Grace
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 02:56 PM
In the inbound action, you can add below condition to exclude emails from other domains
if (email.origemail.indexOf('@calstate.edu')>-1)
{
// Process my inbound actions
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 02:56 PM
In the inbound action, you can add below condition to exclude emails from other domains
if (email.origemail.indexOf('@calstate.edu')>-1)
{
// Process my inbound actions
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 03:24 PM
Sanjiv I'm using a catalog client script and it gives the error message but still allows the user to submit the request.
so users can get around this requirement by changing the email address after the error message shows

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 03:43 PM
You need an onChange script as well as an onSubmit script. And return false in onSubmit
if (variable.indexOf('@calstate.edu')==-1)
{
g_form.addErrorMessage('Please enter a valid email');
return false;
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 02:58 PM
Are you trying to validate in Inbound Action ? If so user below in condition field
email.from.toLowerCase().indexOf('@calstate.edu') != -1
For Client script use below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the page isn't loading and newValue isn't blank
if (isLoading || newValue == '')
return;
// Compare string
validRegExp = /^[a-zA-Z0-9._-]+@(calstate)\.edu$/i;
strEmail = g_form.getValue('email_address');
//search email text for regular exp matches
if (strEmail.search(validRegExp) == -1) {
alert('A valid @calstate.edu e-mail address is required.')
}
}