参考: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-u9FA5uf900-ufa2d]$/; return ext.test(value); }