+ 1
Need help in form validation...
how to validate email address in form using javascript only. i tried following condition but didn't work var eMail = "/^[a-z0-9](\.?[a-z0-9_-]){0,}@[a-z0-9-]+\.([a-z]{1,6}\.)?[a-z]{2,6}$/g"; if (document.myForm.email.value == "" ) { document.myForm.email.focus(); document.getElementById("mail").innerHTML = " * Email cannot be empty"; } else if (document.myForm.email.value == !eMail) { document.myForm.email.focus(); document.getElementById("mail").innerHTML = " * Invalid email"; return false; } else { document.getElementById("mail").innerHtmL = ""; }
4 Réponses
0
Check the following link:
https://www.w3schools.com/js/tryit.asp?filename=tryjs_form_validate_email
0
Try to learn how to use "Regular expressions"
0
You can do it with HTML only
<input type="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}quot; />
0
thanks everyone for help.