javascript - email validation function not working properly -
i have made function validate email using pattern. function not validating it. please , post ur answers in detail possible. thank you.
function getemail(data){ var pattern= /^([a-z][a-z0-9\.]+[a-z0-9])@([a-z][a-z0-9\-]+[a-z0-9])\.([a-z]{2,})(\.[a-z]{2,})$/; if (data==="") { console.log("email-id cannot empty!"); } else if(pattern.test(data)===false) { console.log("enter valid emailid"); } else { var email= "<p>"+data+"</p>"; return email; } }
function validation() { var regemail = /(.+)@(.+){2,}\.(.+){2,}/; //regex pattern email validation //email textbox validation if (regemail.test($('#<textboxid>').val())) { alert('entered email id correct'); } else { alert('please enter valid email address'); } }
Comments
Post a Comment