Friday, 10 February 2017

JQuery regex validation of e-mail check preg_match

var userinput = $(this).val();
var pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i

if (!pattern.test(userinput)) {
    alert('not a valid e-mail address');
}​

No comments:

Post a Comment