Validate multiple email id in a field present in catalog form separated by commas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 05:22 AM
Please let me know how we can check if the value entered in a catalog form field is multiple email id seperated by commas. How we can implement using onchange client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 05:44 AM
You can simply use, split function to get it.
Now lets say you have a field with list of values which are separated by comma.
Sample script:
var a = "a,b,c";
var count = a.split(',');
gs.info(count.length);
Output : 3
You can similarly in a client script:
var emails = g_form.getValue("name_of_the_email_field");
var c = emails.split(',');
if(c.length > 1){
//single email
}
else{
//multiple emails
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 06:21 AM
Hi @Aman Kumar S ,
The code should validate the multiple email id's
For example if user enter test1@example.com,tes2@example.com then it is correct if he enters test1@example.com,test2 then it s...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 06:29 AM
Ah! My bad, it is not simple, apologies for my ignorance.
Found something that should assist you.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 05:51 AM
Lets assume that your variable name is 'multiple_email_id'.
You can use below onChange Client Script to check if each value is email Id or not:
var emailIDs = g_form.getValue('multiple_email_id');
var emailIDList = emailIDs.toString().split(',');
var regex = "^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$"; // Regalar Expression for Email ID validation
for(i=0; i<emailIDList.length ; i++)
{
var result = emailIDList[i].matches(regex);
if(result) {
alert(emailIDList[i] + "is a valid email ID"); // Modify this part according to your requirement
} else {
alert(emailIDList[i] + "is not a valid email ID"); // Modify this part according to your requirement
}
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023