// Regular format validation (anonymous function)
var utils = function(){
var nReg = /^[\d|\.|,]+$/;
var iReg = /\D+/;
var tReg = /\d{3 }-\d{8}|\d{4}-\d{7}/;
var dReg = /^\d{4}-\d{2}-\d{2}\s\d{2} :\d{2}:\d{2}$/;
var eReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([ -.]\w+)*$/;
var mReg = /(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
var zReg=/^[1-9][0-9]{5}$/;
var sReg = /^[\u0391-\uFFE5A-Za-z0-9-\s]+$/; //Cannot enter Special characters (can contain - and spaces)
return {
trim : function(str){ return str.replace(/^\s*|\s*$/g, ''); },
isNumber : function(val){ return nReg.test(val); },
isInt : function(val){ return !iReg.test(val); },
isEmail : function(mail){ return eReg.test(mail); },
isMobile : function(mail){ return mReg.test(mail); },
isTel : function(tel){ return tReg.test(tel); },
isZipCode : function(zipcode){ return zReg.test(zipcode); },
isTime : function(time){ return dReg.test(time); },
isEmpty: function(obj){if(obj != null && obj != "" && typeof(obj) != "undefined"){return false;}else{return true;}},
getStrLength: function (str) {
var cArr = str.match(/[^\x00-\xff]/ig);
return str.length + (cArr == null ? 0 : cArr.length);
},
containSpecial : function(val){ return sReg.test(val); }
};
}();
jQuery validation cannot enter special characters, can contain (- and spaces)
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=327000213&siteId=291194637
Recommended
Ranking