Use Regular expression to validate the Email : EMail : Regular Expressions JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Regular Expressions » EMail »

 

Use Regular expression to validate the Email

















<html>
<head>
<title>E-mail Example</title>
<script type="text/javascript">
    function isValidEmail(sText) {
        var reEmail = /^(?:w+.?)*w+@(?:w+.)+w+$/;
        return reEmail.test(sText);
    }
    function validate() {
        var oInput1 = document.getElementById("txt1");
        if (isValidEmail(oInput1.value)) {
            alert("Valid");
        else {
            alert("Invalid!");
        }

    }
</script>
</head>
<body>
    <P>E-mail Address: <input type="text" id="txt1" /><br />
    <input type="button" value="Validate" onclick="validate()" /></p>

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Regular Expressions
» EMail