我该怎么实现验证通过。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Untitled Page</title>
    <style>
       #prof{border:1px solid red;
 background-color: yellow;
 color: #990020;
 text-align: center;
 width: 200px;height: 28px;}
    </style>
</head>
<body>
    <form action="4.21.html">
        <caption><h2>身份验证程序</h2></caption>
        <table>
            <tr>
                <td><label for="im">请输入你的身份证号</label></td>
                <td><input type="text" id="im"></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="验证"></td>

            </tr>
            <tr>
                <td>验证结果</td>
                <td><div id="prof"></div></td>
            </tr>
        </table>
    </form>
</body>
<script>
 window.onload=function(){
        document.getElementsByTagName("form")[0].onsubmit=function (){
            return validate_form()};

 function validate_form(){
            var myId=document.getElementById("im");
 var prf=document.getElementById("prof");
 var myVu=myId.value;

 if(myVu ==""){
                prf.innerHTML="请输入身份证号!";
 return false;
 }


            if(myVu.length!=18){
                prf.innerHTML="身份证号长度不正确!";
 return false;
 }
            var reg=/^[1-9]/;
 if(!reg.test(myVu)){
                prf.innerHTML="身份证号的第一位只能是1-9之间的数字!";
 return false;
 }
            var reg1=/[\dxX]$/;
 if(!reg1.test(myVu)){
                prf.innerHTML="身份证号的最后一位不正确!";
 return false;
 }
            var reg2=/^.d{16}.$/;
 if(!reg2.test(myVu)){
                prf.innerHTML="身份证号的第二位和最后一位之间出现了非数字字符!";
 return false;
 }
            return true;

 }


    }




</script>
</html>


慕函数1257581
浏览 613回答 0
0回答

慕斯4360584

OKAXULEBBIGOXAEOQDDDKEBEGKWPSJTANKJUBMJWHLFCQIKUOSWLITTUQNDFSMJCMZKMNCZEELELBZOGHFCCTJDKUKBLSFSAHERCVOVVCLHBVSLBUAROHFFCGNDPYGGPUHRBDGJEHCFADLLGFOYVEYBOUFSNWBGGERKUXLZFISCYBEROXKXNNXXZBISHACURHKUNNDDWVCTGLEHUYCERIRENNAXDREBOJMQMFCPKSXEHIJWJMQZJMUBBZDGYIVSVZQAKISZATZSZMWFWGAK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WPMSWCIFOEXCCJORRLOLBDEFHUKLNERHJEOTAXUHELLUIOCSFLCZCSNPZIVPPPWZZXZMCFSIIFISMFSSPPVVMTJ

慕慕5436299

XILOIIOBYCWHKHAEOFSWMWBALLFPQGAHYOBEUFPDJNEETNMJREBYSZEJZZGNORLVDYSVFYIFWJSPWQGJWJYWZQNEDWJNGKXSPMDEHAHELYWTYETGCGJKDNRIMMGNBZUZWGECOOYIAEEEGQKSZFYPZTTFSMAWMJTNCPFAEXDDKOMPSWYPQMPZJQJGQEPRHXEICCZWAXKMDWQRHXIPCYERBVNHYIZKFKBXYSPDQRBTQVPQZWCNCVVBIYCZZMJKIJFKHBLCSPJLDCZWGQKNXOQAGXDHFVHBZWOTWSWAKUEFGQMTJUVFFIWJWTCHYBDTDBIVSPVJJQXXUSMINWNXHULNRRXGDELJDBBQDJGVIGWQKEFOPZFHOLPPMGVAXXHYRIBSQLPIFFCTGNPMFMLPCWBBSBYQYUVIFVCEWJUARFGKUHISCBERXOVSOFSMZGTZTKSIJOLDEXULIERFCWIZBIGEBZDRRXAXGRHOBXPZFSXABEROUEMBYHKMKYEDICOVMYSDAAADXQWTZRRVIZDGJPSEEYHLLVIDJPMTJTNANEDZGCRUOOBZCZQWDTTULGQETCJGDMYSTIWZPCTQTWWEUOKDTQTXXMWALCBCDQUISBMVQKMJANKLULFVOPGAXOBEGMENQXURBWOLCMZTPQQCMGYLUHKRSNAEMWAWWSZTJQDHMCYRLCCZTONYIAABOSFMZWPNEXDALSWCCWK
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript