


JavaScript ID card number verification function (can distinguish authenticity, supports 15 or 18-digit ID number) test error is 0_javascript skills
[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh it to execute
The more direct test code is :
alert(test("ID card number"));
After testing, the above JS verification is too powerful. After entering the correct ID card, an error will be reported if I change any one! It is very practical. It will be easy for everyone to know whether the ID card entered by the user is correct or not. <script> //验证身份证号方法 var test=function(idcard){ var Errors=new Array("验证通过!","身份证号码位数不对!","身份证号码出生日期超出范围或含有非法字符!","身份证号码校验错误!","身份证地区非法!"); var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"xinjiang",71:"台湾",81:"香港",82:"澳门",91:"国外"} var idcard,Y,JYM; var S,M; var idcard_array = new Array(); idcard_array = idcard.split(""); if(area[parseInt(idcard.substr(0,2))]==null) return Errors[4]; switch(idcard.length){ case 15: if ((parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){ ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性 } else{ ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性 } if(ereg.test(idcard)) return Errors[0]; else return Errors[2]; break; case 18: if( parseInt(idcard.substr(6,4)) % 4 == 0 || ( parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){ ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式 } else{ ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式 } if(ereg.test(idcard)){ S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 + parseInt(idcard_array[7]) * 1 + parseInt(idcard_array[8]) * 6 + parseInt(idcard_array[9]) * 3 ; Y = S % 11; M = "F"; JYM = "10X98765432"; M = JYM.substr(Y,1); if(M == idcard_array[17]) return Errors[0]; else return Errors[3]; } else return Errors[2]; break; default: return Errors[1]; break; } } //测试代码 var theid=prompt("请输入身份证号码","15位或18位"); if(theid!=""){ document.write(test(theid)); }else{ //theid=prompt("请输入身份证号码","15位或18位"); } </script>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



An ID card can only open one Taobao store. Sellers should abide by the regulations of the Taobao platform and do not try to use other people's ID cards to open multiple stores. Sellers can expand their business and increase sales by merging stores and opening branches. However, it should be noted that each branch needs to use an independent ID card for real-name authentication.

Mobile phones and ID cards will not be demagnetized together. The reasons are: 1. There are coils and chips integrated inside the ID card. Unlike traditional tapes, hard drives and other storage media, there are no magnetized substances; 2. The electromagnetic radiation of mobile phones is high. Frequency electromagnetic waves, with frequencies as high as hundreds of thousands to tens of millions of Hertz, have no ability to magnetize ID cards. The magnets in the mobile phone speakers will not have a demagnetizing effect on the ID card. We can safely put the ID card and mobile phone together, and pay attention to avoid damage to the ID card and protect its normal use so that it can serve us better.

NFC can recognize ID cards; as early as 2015, China Mobile announced that its own brand N1 has opened the function of NFC to recognize ID cards. Through a special APP, you can use your mobile phone to read ID card information for real-name authentication; once mobile phones become popular for identity recognition It has the function of ID card or ID card, and uses digital password or fingerprint password to improve the security and anti-counterfeiting of its use to a certain extent.

Techniques for extracting ID card information using PHP regular expressions. In actual development, the need to extract ID card information is often used. The ID number is a string containing a lot of information, including region, birthday, gender and other information. In PHP, we can extract ID card information through regular expressions. The following will introduce specific techniques and provide code examples to help you understand better. Extracting regional information from the ID card number. The first 6 digits of the ID card number represent regional information. We can extract this part of the information through regular expressions. by

PHP regular expression is a powerful tool that helps developers process all kinds of text data. In actual development, the verification and extraction of ID numbers are often involved. This article will introduce how to use PHP regular expressions to match ID numbers and provide specific code examples. The ID number is an important piece of personal identification information, usually containing 18 digits and a check code. A valid ID number should comply with certain formats and rules, such as restrictions on date of birth, area code, gender code, etc. Below is one

The ID card is an important document. For websites, apps and other applications, it is often necessary to verify whether the ID number entered by the user meets the specifications. PHP provides a very convenient way to achieve this function, that is, using regular expressions. This article will introduce how to use PHP regular expressions to verify the correct format of the ID card number. 1. ID card number format Before using PHP regular expressions to verify the ID card number format, we first need to understand the format regulations of the ID card number. China’s ID card number format has a total of 18 digits.

Apple noted: “To help ensure that the person adding the ID to Wallet is the same person the ID belongs to, users will be asked to take a selfie and scan the front and back of their driver’s license or state ID card, which will be securely provided to the issuing country for processing. Verification." Part of fraud prevention will include completing "a series of facial and head movements during the setup process." Apple also emphasizes that each state is responsible for "verifying and approving user requests..." Where and how is Apple Digital ID accepted? One of the challenges with all of this is that each state will have its own laws and procedures around how to use Apple Digital IDs, and official support will take time to build. Currently, certain TSA checkpoints at Phoenix International Airport appear to be the only officially supported

PHP is a popular server-side scripting language widely used in website development and data processing. When developing a website or application, it is often necessary to validate and process user-entered data. Among them, the ID number is an important personal identity certification information that requires accurate matching verification. This article will introduce how to use PHP regular expressions to accurately match ID numbers and provide specific code examples. The ID number is the unique identity of a Chinese citizen and contains specific formats and rules. Generally speaking, the ID number
