During Website user registration, it is often necessary to verify the number of digits and letters that some fields contain, because they are not familiar with regular expressions, I 'd like to record this kind of things for use when necessary.
Php verification fields must be 6-15 characters in combination with letters and numbers
If (! Preg_match ("/^ [a-z \ d] {6, 1
Need to use identity card verification work, but also to support the examination of 15-bit and 18-bit.
I temporarily lazy, ask colleagues have no ready-made functions available, colleagues Google a bit, throw me a asp-vbscript version of the function.
But my side is the client JavaScript ah, so with the change Vbs-->js
After the change found good use, and found that VBScript really very long-winded, incredi
JS implements the last digit when the ID card number is 15 to 18 charactersAlgorithm
According to the provisions on the national identity number in the National Standard GB 11643-1999 of the People's Republic of China, the national identity number is a characteristic combination code consisting of a 17-digit digital ontology code and a digital verification code.
The order is from left to right: six-digi
Now we use all 18-digit ID card numbers, and the previous 15-digit ID card numbers. How can we convert a 15-digit ID card number to an 18-digit ID card number?
1. First, after 6th digits
* Wi), i = 0, ..., 16, first the sum of the first 17 digitsAi: Indicates the ID number value of position IWi: A weighted factor representing position I7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4-2
(2) Computational model
Y = mod (S, 11)
(3) The corresponding check code is obtained through the model
Y:0 1 2 3 4 5 6 7 8 9 10Check code: 1 0 X 9 8 7 6 5 4 3 2That is, if you get the remainder of 1 then the final check bit p should be the corresponding 0.
15-di
Function: Upgrade the ID card number of 15 to 18 characters (according to GB 11643-1999)
Parameter: original number (15 digits)
Return Value: the 18-digit number after the upgrade.
Usage: = idcode (A1) (assuming that A1 contains the original 15-digit number)
About the verif
Package cyachina. util;
/*** Created by intellij idea.* User: Administrator* Date: 2004-8-13* Time: 15:37:28* To change this template use file | Settings | file templates.*/Public class idcardutil {
/**** @ Param century 19 for 19xx and 20 for 20xx* @ Param idcardno15 ID card number to be converted* @ Return*/Public static string from15to18 (INT century, string idcardno15 ){
String centurystr = "" + century
1031. Identification of identity card (15) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, YueA valid ID number consists of 17 regions, date number and sequence number plus 1-bit check code. The calculation rules for the checksum code are as follows:The first 17 digits are weighted to sum, the weights are assigned: {7,9
code. Sort order from left to rightIs: Six-digit address code, eight-digit birth date code, three-digit sequence code, and one-digit verification code.
The address code indicates the Administrative Code of the county (city, flag, district) where the resident account of the encoding object is located. The birthdate code indicates the year, month, and day of the encoded object. The year is represented by four digits, and there is no delimiter between
:12010x19890101123411010819671130186637070419881216001xInput Sample 2:2320124198808240056110108196711301862Output Example 2:All passedThinking: Mastering the relationship between global variables and local variables1#include 2 //take the modulus to find the remainder3 4 intweight[ -]={5 7,9,Ten,5,8,4,2,1,6,3,7,9,Ten,5,8,4,26 };7 Charstandard[ One]={8 '1','0','X','9','8','7','6','5','4','3','2' 9 };Ten intMainintargcChar*argv[]) One { A Charstr[ -]; - BOOLAll=true; - intcount;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.