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

What is the regular expression verification of common documents?

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

Share

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

This article is about regular expression verification of commonly used documents. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

/ / ID card verification

JQuery.validator.addMethod ("isIdCard", function (value, element, type) {if ($(type). Val () = ='1') {var re = / (^ / d {15} $) | (^ / d {18} $) | (^ / d {17} (/ d | X | x) $) /; return this.optional (element) | | (re.test (value));} else {return true;}}, "ID card format is incorrect")

/ / passport verification

JQuery.validator.addMethod ("isPassport", function (value, element, type) {if ($(type). Val () = ='2') {var re1 = / ^ [a-zA-Z] {5pm 17} $/; var re2 = / ^ [a-zA-Z0-9] {5pm 17} $/; return this.optional (element) | | (re2.test (value)) | | re1.test (value);} else {return true;}}, "passport format is incorrect")

/ / Hong Kong and Macao pass verification

JQuery.validator.addMethod ("isHKMacao", function (value, element, type) {if ($(type). Val () = ='3') {var re = / ^ [HMhm] {1} ([0-9] {10} | [0-9] {8}) $/; return this.optional (element) | | (re.test (value));} else {return true;}}, "Hong Kong and Macao pass format is incorrect")

/ / Taiwan pass verification

JQuery.validator.addMethod ("isTaiwan", function (value, element, type) {if ($(type). Val () = = "4") {var re1 = / ^ [0-9] {8} $/; var re2 = / ^ [0-9] {10} $/; return this.optional (element) | | (re1.test (value)) | | (re2.test (value))} else {return true;}}, "Taiwan pass is not in the correct format"). Thank you for reading! This is the end of this article on "regular expression verification of commonly used documents". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!

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