Validate Email field

anupchandran
Kilo Contributor

Need a validation scripts to validate Email field. Field should validate (@ and .)

if somebody attempts to enter the email address without @ and .

1 ACCEPTED SOLUTION

Mike Allen
Mega Sage

There is a built in method:



if(oldValue != newValue){


  g_form.hideFieldMsg('email', true);


  if (!isEmailValid(newValue)) {


            g_form.showFieldMsg('email', newValue + " is an invalid email, please re-enter email in correct format.",'error');


  }


}


Capture.PNG


View solution in original post

10 REPLIES 10

hi all,

 

i have a similar solution ...... you may check it out

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var str = g_form.getValue('u_emai');


var n = str.indexOf("@");


var n1 = str.indexOf(".");


if (n == -1 || n1 == -1) {


g_form.addErrorMessage('Please enter the valid email address!');


}

}