1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <script type="text/javascript" src="./jquery-3.5.1.js"></script> <script> let taxId =''; function taxScript(value) { var pattern = new RegExp( "[IOZS]" ); if (pattern.test(value)) { return true; } return false; } function validateTaxId() { let result = true; var taxIdObject = $("#taxId"); var taxId = taxIdObject.val().replace(/\s+/g, ""); taxIdObject.val(taxId.toLocaleUpperCase()); var reg_number=/(^([A-Z0-9]){15,20}$)/; if (taxId=="") { console.log("纳税人识别号不能为空"); result = false; }else if (!reg_number.test(taxId) ) { console.log("纳税人识别号位数限制为15到20位,请检查"); result = false; }else if(taxScript(taxId)){ console.log('纳税人识别号包含特殊字符'); result = false; } return result; } </script>
<p> 税号: <input type="text" id="taxId" value="" onblur="validateTaxId();"> </p>
|