Saturday, 15 March 2014

regex - jQuery email validation regexp problems -



regex - jQuery email validation regexp problems -

i'm working on own validation, have 1 little problem. can't email validation work. have tried different expressions, can't work. maybe did wrong layout?

var email = $('.email'); function valemail(){ var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-za-z]{2,4}|[0-9]{1,3})(\]?)$/; if (filter.test(email)){ homecoming true; } else { homecoming false; } } $('#registerform').submit(function() { if (valemail()) { homecoming true; } else { homecoming false; } });

try :

function isemail(email) { var regex = /^([a-za-z0-9_\.\-\+])+\@(([a-za-z0-9\-])+\.)+([a-za-z0-9]{2,4})+$/; homecoming regex.test(email); }

the next calls:

$('#registerform').submit(function(){ if(isemail($(this).val())==false){ //do validation not satisfied }else{ //do } });

jquery regex validation email

No comments:

Post a Comment