Auto license plate JS Regular expression verification (including new energy license plate)

Source: Internet
Author: User

/**
* First: Ordinary cars


* License plate number format: Kanji + A-z + 5 bit A-Z or 0-9 (license plate number does not exist letter I and O Prevent and 1, 0 confusion)


* (only common license plate number, Coach car, police grade.) Some of the troop vehicles, new energy is not included)


* BEIJING-Tianjin-Shanghai-Chongqing-Hebei-Henan-Liaoning-Hunan-Anhui-Shandong-New Su-zhe-gan-Guiganjin Mongolian-Shaanxi-Gi Jingui-Guangdong-Qinghai-Tibet Tranning-Shenlan Jinan Guang Cheng Ling


* Regular car rules: "[Beijing, Tianjin, Shanghai, Hebei, Henan, Liaoning, Hunan, Anhui Lu Xin su zhe jiang gan e Guiganjin Mongolia Shaanxi Gi Jingui Guangdong Qinghai-Tibet Kanningjong make the collar a-z]{1}[a-z]{1}[a-hj-np-z0-9]{4}[a-hj-np-z0-9 hang Learning Police Hong Kong and Macao]{1}"


*
* Second: New energy vehicle


* Composition: Province abbreviation (1 characters) + Licensing Agency code (1 letters) + serial number (6 digits), total 8 characters, serial number cannot appear letter I and letter O


* General rules: case-insensitive, first: province abbreviation (1 kanji), second: Licensing Agency code (1-letter)


* Number of digits:


* Small car, first: can only use the letter D or the letter F, second digit: the letter or the number, the next four digits: must use the number


*---([df][a-hj-np-z0-9][0-9]{4})


* Large car, first five digits: must use number, sixth digit: only with letter D or letter F.


*----([0-9]{5}[DF])


* New Energy Vehicle Rules: "[Beijing, Tianjin, Shanghai, Hebei, Henan, Liaoning, Hunan, Anhui Lu Xin su zhe jiang gan Guiganjin Meng Shan Gi Jingui Yue Qinghai-Tibet Kanningjong Collar A-z]{1}[a-z]{1} ([0-9]{5}[DF]) | ( [DF] [A-hj-np-z0-9] [0-9] {4})) "


* /

Verify the license plate number JS method:

1 //License plate number Verification method2 3 functionIsvehiclenumber (vehiclenumber) {4 5   varXreg=/^[Jing Jin Hu yu ji yu Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Mongolian Shaanxi Gi Jingui Guangdong Qinghai-Tibet Kanningjong Collar A-z]{1}[a-z]{1} (([0-9]{5}[df]$] | ( [DF] [A-hj-np-z0-9] [0-9] {4}$))/;6 7   varCreg=/^[Jing Jin Shanghai yu ji yu Yun Liao Hei Xiang Wan lu xin su zhe gan e Guiganjin Mongolia Shaanxi Gi Jingui Guangdong Qinghai-Tibet Kanningjong led a-z]{1}[a-z]{1}[a-hj-np-z0-9]{4}[a-hj-np-z0-9 Hung learning Police Hong Kong and Macao]{1}$/;8 9   if(Vehiclenumber.length = = 7){Ten  One     returncreg.test (vehiclenumber); A  -}Else if(Vehiclenumber.length = = 8){ -  the     returnxreg.test (vehiclenumber); -  -}Else{ -  +     return false; -      +   } A  at}

General nationwide, if in doubt, please leave a message.

Auto license plate JS Regular expression verification (including new energy license plate)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.