Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the regular expression of 15-bit 18-bit ID card number verification

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to achieve the regular expression of 15gamma 18-bit ID card number verification", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve 15gamma 18-bit ID card number verification regular expression" this article.

Introduction

Xxxxxx yyyy MM dd 3750 18 bits

Xxxxxx yy MM dd 750 15 bits

Region: [1-9]\ d {5}

Top two places of the year: (18 | 19 | ([23]\ d)) 1800-2399

The last two places of the year:\ d {2}

Month: (0 [1-9]) | (10 | 11 | 12))

Number of days: ([0-2] [1-9]) | 10 | 20 | 30 | 31) 29 + cannot be prohibited in leap years

Three-digit sequence code:\ d {3}

Two-digit sequence code:\ d {2}

Check code: [0-9Xx]

Regular expression

Eighteen digits: ^ [1-9]\ d {5} (18 | 19 | ([23]\ d))\ d {2} ((0 [1-9]) | (10 | 11 | 12)) ([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {3} [0-9Xx] $

Fifteen digits: ^ [1-9]\ d {5}\ d {2} ((0 [1-9]) | (10 | 11 | 12)) (([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {2} $

Total:

(^ [1-9]\ d {5} (18 | 19 | ([23]\ d))\ d {2} ((0 [1-9])) | (10 | 11 | 12)) ([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {3} [0-9Xx] $) | (^ [1-9]\ d {5}\ d {2} (0 [1-9]) | (10 | 11 | 12)) ([0-2] [1-9]) | 10 | 20 | 30 | 31)\ d {2} $)

Simple example of JS verification

Function isCardNo (card) {/ / ID card number is 15 or 18 digits, all 15 digits are digits, the first 17 digits of 18 digits are digits, and the last digit is check bit. It may be a number or character X var reg = / (^\ d {15} $) | (^\ d {18} $) | (^\ d {17} (\ d | X | x) $) /; if (reg.test (card) = false) {alert ("illegal ID card input"); return false }} the above is all the contents of this article entitled "how to implement the regular expression for verifying an 18-bit ID card number in 15max". Thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report