通过正则进行js验证身份证号码: var numRegex = /^([a-zA-Z\d_]{1,18})$/; if (!numRegex.test(val)) { return '请输入身份证号码或格式不正确!' ; }