參考:https://blog.csdn.net/xxjmlgb/article/details/49467717 ...
參考:https://blog.csdn.net/xxjmlgb/article/details/49467717
var valNull;//非空校驗 var valSpecial;//特殊字元校驗 var valLen;//長度校驗 var valIdc;//身份證 var valBank;//銀行卡 var postCodeVal;//郵編 var mailVal;//郵件 var valEn;//字母 var valNum;//數字 var valDou;//小數 var valTel;//電話 - 座機 var valMob;//手機 var isChinese;//中文 valNull = function(value){ if(value.trim(value).length == 0){ return false; }else{ return true; } } valSpecial = function(value){ var ext = /[\!\@\#\$\%\^\&\*~<>',\.]/; return ext.text(value); } valLen = function(value,len){ if (value.length > len){//超過要求長度 return false; } else{ return true; } } valIdc = function(value){ var ext = /(^\d{15}&)|(^\d{18})|(^\d{17}(\d|X|x)$)/; return ext.test(value); } valBank = function(value){ var ext = /^[0-9]{16,19}$/; return ext.test(value); } postCodeVal = function(value){ var ext = /^\d{6}$/; return ext.test(value); } mailVal = function(value){ var ext = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/; return ext.test(value); } valEn = function(value){ var ext = /(^[a-zA-Z]+$)/; return ext.test(value); } valNum = function(value){ var ext = /^[0-9]*$/; return ext.test(value); } valDou = function(value){ var ext = /^[0-9]+(.[0-9]{1,3})?$/; return ext.test(value); } valTel = function(value){ var ext = /^\d{3,4}-\d{7,8}(-\d{3,5})*$/; return ext.test(value); } valMob =function(value){ var ext = /^1[3456789]\d{9}/; return ext.test(value); } isChinese = function(value){ var ext = /^[\u4E00-\u9FA5\uf900-\ufa2d]$/; return ext.test(value); }