js正则表达式手机号(邮箱)验证

 

js正则表达式手机号(邮箱)验证

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script type="text/javascript">
    function checkMobile(){
        var sMobile = document.mobileform.mobile.value
///^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/

        if(!(/^1[3|5][0-9]d{4,8}$/.test(sMobile))){
            alert("不是完整的11位手机号或者正确的手机号前七位");
            document.mobileform.mobile.focus();
            return false;
        }
    }
</script>
<form action="" name="mobileform" method="post" onSubmit="return checkMobile();">
    <INPUT name="mobile" class=tdc size="40" maxLength="11">
    <INPUT name="action" type="hidden" value=mobile> <INPUT class=bdtj name=B1 type=submit value="查 询">
</FORM>
</body>
</html>
原文地址:https://www.cnblogs.com/wzzl/p/4877433.html