Blogger Information
Blog 67
fans 0
comment 2
visits 72026
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js 证件验证、手机号码验证
搁浅
Original
530 people have browsed it
  1. /*身f证验证*/
  2. let cardId=445222198409130049
  3. if (!(/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(\d|x|X)$/.test(cardId))) {
  4. console.log('身f证格式错误');
  5. } else {
  6. console.log('身f证正确');
  7. }
  8. /*回乡证验证*/
  9. if (!(/(H|M)(\d{10})$/.test(cardId))) {
  10. console.log('回乡证格式错误');
  11. } else {
  12. console.log('回乡证正确');
  13. }
  14. /*港澳居民来往内地通行证*/
  15. if (!(/^([A-Z]\d{6,10}(\(\w{1}\))?)$/.test(cardId))) {
  16. console.log('港澳证格式错误');
  17. } else {
  18. console.log('港澳证正确');
  19. }
  20. /*手机号码验证*/
  21. if (!(/^1\d{10}$/.test(cardId))) {
  22. console.log('港澳证格式错误');
  23. } else {
  24. console.log('港澳证正确');
  25. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post