标签:
1、验证是否为浮点数
2、验证整数
function isInteger(obj) { return typeof obj === ‘number‘ && obj%1 === 0 } function isInteger(obj) {
return Math.floor(obj) === obj } function isInteger(obj) {
return parseInt(obj, 10) === obj } function isInteger(obj) {
return (obj | 0) === obj }function isSpecial(str) {
return ((/^(\‘)+|(\’)+|(\")/).test(str));
}
//验证邮箱
function isEmail(str) {
return ((/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/).test(str));
}
// 求字符串的字节数
String.prototype.getBytesLength = function () {
var length = 0;
for (i = 0; i < this.length; i++) {
iCode = this.charCodeAt(i);
if ((iCode >= 0 && iCode <= 255) || (iCode >= 0xff61 && iCode <= 0xff9f)) {
length += 1;
} else {
length += 2;
}
}
return length;
}
标签:
原文地址:http://www.cnblogs.com/csywustc/p/4662651.html