Home  >  Article  >  Web Front-end  >  Specific implementation of the complete method of verifying ID cards in javascript_javascript skills

Specific implementation of the complete method of verifying ID cards in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:14:221041browse

Copy code The code is as follows:

var certCardValid = function(id){
      var arrVerifyCode = [1,0,"x",9,8,7,6,5,4,3,2];
var wi = [7,9,10,5,8,4,2,1 ,6,3,7,9,10,5,8,4,2];
var Checker = [1,9,8,7,6,5,4,3,2,1,1];
var msg = "";
if(id.length != 15 && id.length != 18) {
var msg = ""; Or 18 bits. ");
                                                                                    ; "19" id.slice(6,16);


if (!/^/d $/.test(ai)) {
Ext.MessageBox.alert("Message prompt" ,"Except for the last digit, the ID card must be a number.");
              return false; > var mm = ai.slice(10,12)-1;
var dd = ai.slice(12,14);
var d = new Date(yyyy,mm,dd);
var now = new Date();
var year = d.getFullYear();
var mon = d.getMonth();
var day = d.getDate();


          if (year != yyyy || mon != mm || day != dd) {
                Ext.MessageBox.alert("Message prompt", "The ID card is invalid. ");
                                                ; i) * wi[i];
}

ai = arrVerifyCode[ret %= 11];
ai = ai.toUpperCase();


if( id.length == 18 && id != ai){
             Ext.MessageBox.alert("Message prompt", "The ID card is invalid."); ;
};


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn