JavaScript 学习中

邮箱的验证:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>email</title>
        <script type="text/javascript">
            window.onload=isEmail;
            function isEmail(){
                var getValue=document.getElementById("zh_e");
                var getBtn=document.getElementById("btn");
                var getReset=document.getElementById("reset");
                var emial=/^([a-zA-Z0-9]+[_|/_|/.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|/_|/.]?)*[a-zA-Z0-9]+/;
                getBtn.onclick=function(){
                    if(getValue.value==""||!(emial.test(getValue.value))){
                        alert("input!");
                    }
                    else{
                         alert("you are right!");
                    }
                }
                getReset.onclick=function(){           //
                    getValue.value="";                     //
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <input type="text" maxlength="32" id="zh_e" /><br />
        <input type="button" name="btn" id="btn" value="btn" />
        <input type="button" name="reset" id="reset" value="reset" />
    </body>
</html>

原文地址:https://www.cnblogs.com/webph/p/5115173.html