Native Javascript phone number verification, email verification, ID card verification. When using, pass in the string to be verified, return true to indicate compliance, and return false if the code does not match.
Use:
document.getElementById("btnPhone").onclick=function(){ alert(ValidationHandler.IsPhone(document.getElementById("phoneInput").value)==true?"合法":"不合法") }; document.getElementById("btnEmail").onclick=function(){ alert(ValidationHandler.IsEmail(document.getElementById("emailInput").value)==true?"合法":"不合法") }; document.getElementById("btnIdCard").onclick=function(){ alert(ValidationHandler.isIDCard(document.getElementById("idCardInput").value)==true?"合法":"不合法") };
Operation rendering:
The above is the entire content of this article. I hope it will be helpful for everyone to learn the Javascript data validation plug-in.