Javascript reguular expression

var phoneno = /^\d{10}$/;

 

/* only number reg exp. */

var phoneno = /^\d+$/;

jQuery(‘#terms’).attr(‘checked’); /* if checked */

 

Check mail using regular expression.
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if(regex.test($(‘#contact_email’).val()) == false){

valid = false;

$(‘#contact_email’).parent().addClass(‘has-error’);

}

Leave a Reply