var sidpatrn1 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/; var sidpatrn2 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}[0-9Xx]?$/; if (!sidpatrn1.exec(document.getElementById('accountSID').value) && !sidpatrn2.exec(document.getElementById('accountSID').value)) { alert('请输入正确的身份证号码'); return false; }