STK.register("common.setting.rule", function(a) {
var b = {};
b.isEmpty = function(a) {
return /^\s*$/g.test(a.replace(/^\s+|\s+$/g, ""))
};
b.isNumber = function(a) {
return /^[+\-]?\d+(\.\d+)?$/.test(a)
};
b.isName = function(a) {
return /^[0-9a-zA-Z\u4e00-\u9fa5_-]+$/.test(a)
};
b.isCompany = function(a) {
return /^[0-9a-zA-Z\u4e00-\u9fa5\uff08\uff09()]+$/.test(a)
};
b.isChinese = function(a) {
return /[\u4e00-\u9fa5]+$/.test(a)
};
b.isCName = function(a) {
return /^[\u4e00-\u9fa5]+[\u00b7\.]?[\u4e00-\u9fa5]+$/.test(a)
};
b.isEmail = function(a) {
if (!/^[0-9a-z_][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\.){1,4}[a-z]{2,4}$/.test(a))
return !1;
if (a && a != "" && a.indexOf("@") != -1) {
var b = a.indexOf("@"), c = a.substring(0, b);
return c.length > 64 || a.length > 256 ? !1 : !0
}
return !1
};
b.isEmailName = function(a) {
return /^[0-9a-z_][_.0-9a-z-]{0,31}$/.test(a)
};
b.isIDNumber = function(a) {
return /^[\d]{15}$/.test(a) || /^[\d]{17}([Xx\d]{1}$)$/.test(a)
};
b.isMobile = function(a) {
return /^1[3|4|5|8][0-9]{9}$/.test(a)
};
b.isWeird = function(a) {
return !/^[a-zA-Z0-9\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b\uFF01\u201c\u201d\u2018\u2019\u300e\u300f\u300c\u300d\uFF09\uFF08\.\_\-\?\~\!\@\#\$\%\^\&\*\\\+\`\=\[\]\(\)\{\}\|\;\'\:\"\,\/\<\>]+$/i.test(a)
};
b.isPassportID = function(a) {
return /^[a-zA-Z0-9]{8,20}$/.test(a)
};
b.isAbroadName = function(a) {
return /^[a-zA-Z\u4e00-\u9fa5]+([\u00b7\.\- ]?[a-zA-Z\u4e00-\u9fa5]+)*$/.test(a)
};
b.lenLimit = function(b, c, d) {
var e = a.bLength(b);
return !(e < c || e > d)
};
b.isUrl = function(a) {
return /^http:\/\/([\w-]+(\.[\w-]+)+(\/[\w- .\/\?%@&+=\u4e00-\u9fa5]*)?)?$/i.test(a)
};
b.turnBoolean = function(a) {
switch (typeof a) {
case "boolean":
return a;
case "number":
return !!a;
case "string":
return a == "true" || a == "1"
}
};
b.reNullChar = function(a) {
return a.replace(/^\s+|\s+$/g, "")
};
return b
});