身份证验证
<!DOCTYPE html > < html lang= "en" > < head > < meta charset= "UTF-8" > < title > Title </ title > < script src= "https://cdn.bootcss.com/jquery/3.2.1/jquery.js" ></ script > </ head > < body > < input type= "text" class= "" id= "card" > < input type= "submit" class= "" id= "sub" > < script > $ ( function () { $ ( "#sub" ). click ( function () { var val = $ ( "#card" ). val (); var isidcardlen = val . length var reg15 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/ ; var reg18 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Z])$/ ; if ( isidcardlen == 15