Home >Web Front-end >JS Tutorial >Commonly used Javascript data validation plug-ins_Basic knowledge

Commonly used Javascript data validation plug-ins_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 15:47:271160browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn