Category:js
Article From:https://www.cnblogs.com/coder-lzh/p/9061691.html

Verify whether the cell phone number is correct

// Determine whether it is a cell phone number
 isPoneAvailable: function (pone) {  
   var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;  
   if (!myreg.test(pone)) {  
     return false;  
   } else {  
     return true;  
   }  
 },  
 // Judge whether it is a telephone number
 isTelAvailable: function (tel) {  
   var myreg = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;  
   if (!myreg.test(tel)) {  
     return false;  
   } else {  
     return true;  
   }  
 },  

Verify whether the identity card number is correct or not

function isCardNo(card)  
{  
   // The ID card number is 15 bits or 18 bits, 15 digits are all numbers, 18 first 17 figures, and the last one is check digit, maybe digit or character X.
   var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;  
   if(reg.test(card) === false)  
   {  
       alert("ID card input is not legal ");  
       return  false;  
   }  
}  

 

Link of this Article: Various verification of JS

Leave a Reply

Your email address will not be published. Required fields are marked *