- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 09:37 AM
This code is not validating any email addresses after the first one. Any help would be appreciated!
function onChange(control, oldValue, newValue, isLoading, isTemplate){
var err_field = control.id;
var err_flag = 'false';
var err_message = 'Invalid Email Address format. Format should be like: abc@domain.com';
var group_members = g_form.getValue('str1');
var member_split = group_members.split(',');
for (var n = 0; n < member_split.length; n++) {
var member_info = member_split[n];
regex = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/ig;
err_flag = regex.test(g_form.getValue(err_field));
g_form.hideErrorBox(err_field);
if (!err_flag) {
g_form.hideFieldMsg('req_inbox');
g_form.showFieldMsg(err_field, err_message, 'error');
}
else {
g_form.hideErrorBox(err_field);
}
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 10:15 AM
Here you go. Use this script
function onChange(control, oldValue, newValue, isLoading, isTemplate){
var err_field = control.id;
var err_flag = true;
var err_message = 'Invalid Email Address format. Format should be like: abc@domain.com';
g_form.hideErrorBox(err_field);
var group_members = g_form.getValue('str1');
var member_split = group_members.split(',');
for (var n = 0; n < member_split.length; n++) {
var member_info = member_split[n].trim();
regex = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/ig;
err_flag = regex.test(member_info);
if (!err_flag) {
break;
}
}
if(!err_flag){
g_form.hideFieldMsg('req_inbox');
g_form.showFieldMsg(err_field, err_message, 'error');
}
else{
g_form.hideErrorBox(err_field);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 11:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2021 10:38 PM
how to write onsubmit client script for validating email a list of selected users in list collector

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 11:36 AM
You are still using your old script. Use my script as is. You should be good to go. Make sure you use correct field name in g_form.getValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 11:52 AM
It is working now, thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 11:55 AM
Glad I could help. Please mark my response as correct and close the thread.
If you are viewing this from the community inbox you will not see the correct answer button. You need to open the thread directly and you will see a correct answer button with red star. Please review this How To Mark Answers Correct From Community Inbox