Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Regex validation for email addresses not working in client script

Tomi Corigliano
Kilo Sage

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.');
	}
   
}

 

 

 

1 ACCEPTED SOLUTION

Tomi Corigliano
Kilo Sage

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");
}

View solution in original post

5 REPLIES 5

Tomi Corigliano
Kilo Sage

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");
}