js ID card judgment method supports 15 and 18 digits_javascript skills
//There should be an input box with the id identity_card on the HTML page, and a place to prompt a message when the ID card with the id ipmessage is incorrect or correct
<script> <BR>//Identity Certificate verification <BR>$(document).ready(function(){ <BR>$("#identity_card").change(function(){ <BR>var idcard =$(this).val(); <BR>checkDate(idcard ); <BR>}); <BR>}); <BR>//ID card<BR>function checkDate( idcard ){ <BR>var socialNo = idcard; <BR>if(socialNo == "") <BR>{ <BR>$('#ipmessage').html('The format of the input ID number is incorrect, it must be a 15-digit to 18-digit ID number'); <BR>alert("Enter ID number cannot be empty!"); <BR>return (false); <BR>} <BR>if (socialNo.length != 15 && socialNo.length != 18) <BR>{ <BR>$( '#ipmessage').html('The format of the entered ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert("The format of the entered ID number is incorrect!"); <BR>return (false); <BR>} <BR>var area={11:"Beijing",12:"Tianjin",13:"Hebei",14:"Shanxi",15:"Inner Mongolia",21:" Liaoning",22:"Jilin",23:"Heilongjiang",31:"Shanghai",32:"Jiangsu",33:"Zhejiang",34:"Anhui",35:"Fujian",36:"Jiangxi" ,37:"Shandong",41:"Henan",42:"Hubei",43:"Hunan",44:"Guangdong",45:"Guangxi",46:"Hainan",50:"Chongqing",51 :"Sichuan",52:"Guizhou",53:"Yunnan",54:"Tibet",61:"Shaanxi",62:"Gansu",63:"Qinghai",64:"Ningxia",65:" Xinjiang",71:"Taiwan",81:"Hong Kong",82:"Macau",91:"foreign"}; <BR>if(area[parseInt(socialNo.substr(0,2))]==null ) { <BR>$('#ipmessage').html('The format of the input ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert("The ID number is incorrect ( Illegal in the region)!"); <BR>return (false); <BR>} <BR>if (socialNo.length == 15) <BR>{ <BR>pattern= /^d{15}$/; <BR>if (pattern.exec(socialNo)==null){ <BR>$('#ipmessage').html('The format of the entered ID number is incorrect, it must be a 15-digit to 18-digit ID number') ; <BR>alert("The 15-digit ID number must be numeric! "); <BR>return (false); <BR>} <BR>var birth = parseInt("19" socialNo.substr(6,2)); <BR>var month = socialNo.substr(8,2) ; <BR>var day = parseInt(socialNo.substr(10,2)); <BR>switch(month) { <BR>case '01': <BR>case '03': <BR>case '05' : <BR>case '07': <BR>case '08': <BR>case '10': <BR>case '12': <BR>if(day>31) { <BR>$('# ipmessage').html('The format of the entered ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert('The format of the entered ID number is incorrect!'); <BR>return false; <BR>} <BR>break; <BR>case '04': <BR>case '06': <BR>case '09': <BR>case '11': <BR>if(day> 30) { <BR>$('#ipmessage').html('The format of the entered ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert('The entered ID number is incorrect The format is correct!'); <BR>return false; <BR>} <BR>break; <BR>case '02': <BR>if((birth % 4 == 0 && birth % 100 != 0) | | birth % 400 == 0) { <BR>if(day>29) { <BR>$('#ipmessage').html('The format of the input ID number is incorrect, it must be an identity of 15 to 18 digits ID number'); <BR>alert('The format of the entered ID number is incorrect!'); <BR>return false; <BR>} <BR>} else { <BR>if(day>28) { <BR>$('#ipmessage').html('The format of the entered ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert('The format of the entered ID number is incorrect!') ; <BR>return false; <BR>} <BR>} <BR>break; <BR>default: <BR>$('#ipmessage').html('The format of the input ID number is incorrect, it must be 15 ID number to 18 digits'); <BR>alert('The format of the entered ID number is not correct!'); <BR>return false; <BR>} <BR>var nowYear = new Date().getYear (); <BR>if(nowYear - parseInt(birth)<15 || nowYear - parseInt(birth)>100) { <BR>$('#ipmessage').html('Enter the ID number format. Correct, it must be an ID number of 15 to 18 digits'); <BR>alert('The format of the entered ID number is not correct!'); <BR>return false; <BR>} <BR>$('# ipmessage').html('Passed! '); <BR>return (true); <BR>} <BR>var Wi = new Array( <BR>7,9,10,5,8,4,2,1,6, <BR>3, 7,9,10,5,8,4,2,1 <BR>); <BR>var lSum = 0; <BR>var nNum = 0; <BR>var nCheckSum = 0; <BR>for (i = 0; i < 17; i) <BR>{ <BR>if ( socialNo.charAt(i) < '0' || socialNo.charAt(i) > '9' ) <BR>{ <BR>$('#ipmessage').html('The format of the entered ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert("The format of the entered ID number is incorrect!") ; <BR>return (false); <BR>} <BR>else <BR>{ <BR>nNum = socialNo.charAt(i) - '0'; <BR>} <BR>lSum = nNum * Wi[ i]; <BR>} <BR>if( socialNo.charAt(17) == 'X' || socialNo.charAt(17) == 'x') <BR>{ <BR>lSum = 10*Wi[ 17]; <BR>} <BR>else if ( socialNo.charAt(17) < '0' || socialNo.charAt(17) > '9' ) <BR>{ <BR>$('#ipmessage ').html('The format of the entered ID number is incorrect, it must be a 15- to 18-digit ID number'); <BR>alert("The format of the entered ID number is incorrect!"); <BR>return ( false); <BR>} <BR>else <BR>{ <BR>lSum = ( socialNo.charAt(17) - '0' ) * Wi[17]; <BR>} <BR>if ( (lSum % 11) == 1 ) <BR>{ <BR>$('#ipmessage').html('Passed!'); <BR>return true; <BR>} <BR>else <BR>{ <BR>$('#ipmessage').html('The format of the input ID number is incorrect, it must be 15 to 18 digits ID number'); <BR>alert("The format of the entered ID number is incorrect!"); <BR>return (false); <BR>} <BR>} <BR></script>

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools
