php - jquery mail validation submits the form -


i have jquery validate email id,but after validation submits form instead of preventing it.

my code is

$(document).ready(function(e) {     $('#personaledits').click(function(e) {         $('#persemail').each(function(e) {             email_address = $(this);             email_regex = /^[a-za-z0-9._-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/i;             if(!email_regex.test(email_address.val())){  alert('please enter valid email'); e3.preventdefault(); return e.preventdefault(); return false; }          });     }); }); 

try this:

$(document).ready(function () {  // event not required here     $('#personaledits').click(function (e) {         $('#persemail').each(function () {             email_address = $(this);             email_regex = /^[a-za-z0-9._-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/i;             if (!email_regex.test(email_address.val())) {                 alert('please enter valid email');                 e.preventdefault();    // need prevent click event here                 return false;             }         });     }); }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -