下面是我常用一些JS验证和函数,有一些验证我直接写到了对象的属性里面了,可以直接通过对象.方法来调用
} } else { rad = rad.FormatLen(len); } return numpart + "." + rad; }
sTmpStr = new String(sTargetStr); nOriginLen = sTmpStr.length;
for (var i = 0; i < nOriginLen; i++) { sTmpChar = sTmpStr.charAt(i);
if (escape(sTmpChar).length > 4) { nStrLength += 2; } else if (sTmpChar != '\r') { nStrLength++; } }
return nStrLength; }
if (/(y+)/.test(format)) { format = format.replace(RegExp.$1,(this.getFullYear() + "").substr(4 - RegExp.$1.length)); }
for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1,RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; }
function HasChinese(value) { if (/^[\u4e00-\u9fa5]+$/.test(value)) { return true; } return false; }
function ToDate(dateStr) { var dStr = dateStr.toString(); dateStr = dStr.replaceAll("-","/");
return new Date(Date.parse(dateStr)); }