I am wanting to check if an input field has the attribute \"pattern\" and if so, preform a regex check aganst said pattern.I know this is already done by HTML5, but I am wan
Below is the proper way to validate a text-box based on a regular Expression using Jquery in MVC. Please note that this expression is made to validate multi email addresses in one string:
var emailReg = new RegExp(/^([A-Z0-9.%+-]+@@[A-Z0-9.-]+.[A-Z]{2,6})*([,;][\s]*([A-Z0-9.%+-]+@@[A-Z0-9.-]+.[A-Z]{2,6}))*$/i);
var emailText = $('#email').val();
if (!emailReg.test(emailText)) {
alert('Wrong Email Address\Addresses format! Please reEnter correct format');
return false;
}
}