주민등록번호 검사 --------- 프런트엔드

17777 단어
         

       :
  
 
    :
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>         title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js">script>
<script>
    $(function(){
    $('.btn').click(function(){
        let orginnumber =$('.number').val();
        let partn = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;//              
        if (!partn.exec(orginnumber))
        {
        alert('');
        }else{
            let number = [...orginnumber]; //es6  ,  ...         。
            let ration= new Array("7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2");//  
            let ration22= new Array("1","0","X","9","8","7","6","5","4","3","2");
            let sum=0;
            console.log(ration);
                for(let i=0;i<number.length-1;i++){
                    sum=number[i]*ration[i]+sum;
                        console.log(i);
                }
                let mod = sum%11;
                if(ration22[mod]==number[17]){
                    alert('  ');
                }else{
                    alert('   ');
                }
            }
        })
    })
script>
head>
    <body>
        <div>
            <lable for="input">lable><input type="text" class="number"/><button class="btn">  button>
        div>
    body>
html>

좋은 웹페이지 즐겨찾기