js處理根據輸入的身份證號自動匹配出生年月
阿新 • • 發佈:2019-01-25
<span style="font-family: Arial, Helvetica, sans-serif;"><script language="javascript" type="text/javascript"></span>
<span style="font-family: Arial, Helvetica, sans-serif;"> function lostFocus() {</span>
var m = document.getElementById("<%=txtPatientCardNum.ClientID %>").value;<span style="font-family: Arial, Helvetica, sans-serif;">//證件號控制元件</span> var n = m.substring(6, 10) + "-" + m.substring(10, 12) + "-" + m.substring(12, 14); //var str = /^[A-Za-z]*$/; if (/^\d+$/.test(m.substring(6, 14))) { document.getElementById("<%=txtBirth.ClientID %>").value = n;//填充生日控制元件 } else { alert("請檢身份證輸入是否正確!"); document.getElementById("<%=txtPatientCardNum.ClientID %>").focus(); //證件號控制元件 //document.getElementById("<%=txtPatientCardNum.ClientID %>").style.backgroundColor = "#ff0000"; } <%-- alert(document.getElementById("<%=txtBirth.ClientID %>").value);--%> }
</script>