How can add validation for email and Mobile number?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

Hi @Svm Rvndvll​

You can use JavaScript regular expression or you can write the your own logic to validate the email and phone number. Below are the syntax,

function ValidateEmail(mail)

{

if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))

{

return (true)

}

alert("You have entered an invalid email address!")

return (false)

}

function validatePhone(phone) {

var error = "";

var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');

if (stripped == "") {

error = "You didn't enter a phone number.";

} else if (isNaN(parseInt(stripped))) {

phone = "";

error = "The phone number contains illegal characters.";

} else if (!(stripped.length == 10)) {

phone = "";

error = "The phone number is the wrong length. Make sure you included an area code.\n";

}

}

Hello @Svm Rvndvll​

Did my response help you? If yes, make sure you click [Select as Best] under the response to close out the post.

thank you soo much sir..

your code is very helpful and its working good..