javascript - Validating email using js -
i trying create form allows people submit email using @msu.edu email. have alert coming when it's not msu.edu email, when use email test@msu.edu not submitting form.
function checkmail() { var email = document.validation.email.value.tolowercase(); var filter = /^([\w-]+(?:\.[\w-]+)*)@msu.edu/i; var result = filter.test(email); alert('valid email found: ' + result); return result; }
you need escape .
there.
correct code:
function checkmail() { var email = document.validation.email.value.tolowercase(); var filter = /^([\w-]+(?:\.[\w-]+)*)@msu\.edu/i; // ^-- escape dot var result = filter.test(email); alert('valid email found: ' + result); return result; }
Comments
Post a Comment