
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 05:09 AM
Since I cannot use the Question Regular Expression for a multi line text variable in a catalog item, I'm trying to do the reg ex validation for email addresses through a catalog client script. However I can't get it to work properly.
Can anyone please help me to get the right value for the regex. I tried several combinations
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regex = '-----BEGIN EMAIL VALIDATION-----^([a-zA-Z0-9])$-----END EMAIL VALIDATION-----';
//Regex for RSA key (Private part)
if(!newValue.match(regex)){
g_form.addErrorMessage('Please enter valid email addresses.');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 11:25 PM
Thank you @Community Alums
I had to alter the code a little bit to have it work:
if (!newValue.match(/^[a-zA-Z0-9\_\-\.]+@[a-zA-Z0-9\_\-\.]+\.[a-zA-Z]{2,5}$/)) {
g_form.showFieldMsg("google_group_members_00","Please enter a valid email ID","Error");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 07:12 AM
Hello,
Please check the below post on the same:-
Please mark my answer as correct based on Impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 07:19 AM
Hi @Tomi Corigliano ,
Below support article should assist you:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0661825
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 07:19 AM
Hello @Tomi Corigliano
Could you please try below code -
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (!newValue.match(/^[a-zA-Z0-9_\-\.]+\@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}$/)) {
g_form.addErrorMessage("Please enter a valid email ID");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 07:23 AM
If you navigate to Service Catalog > Catalog Variables > Variable Validation Regex, there you might Email regex. If that works for you then try utilizing that in your script. See the below image for reference.