email validation in JavaScript
Hi friends In this JavaScript Lesson we are going to learn how to email validation in JavaScript.. just follow the below example to learn JavaScript email validation..email validation in JavaScript |
validate.html
<html> <body> <h2>email validation in JavaScript </h2> <input type="text" id="Email"> <button type="button" onclick="ValidateFunction()">Submit</button> <p id="result" style="color: red;"></p> <script> function ValidateFunction() { var email; email = document.getElementById("Email").value; var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if (reg.test(Email.value) == false) { document.getElementById("result").style.color = "red"; document.getElementById("result").innerHTML =email+' is Invalid Email Address'; return false; } else{ document.getElementById("result").style.color = "green"; document.getElementById("result").innerHTML =email+"is Valid Email"; } return true; } </script> </body> </html>
That's it Friends Email validation in JavaScript ..Thank You for Visiting..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.