1. 手机号码
//不是严格判断
/(^1[3|4|5|7|8][0-9]\d{8}$)|(^0((10)|(2[0-9])|([3-9][0-9]{2}))[-]?[0-9]{7,8}$)/
2. 车牌号码
/^[\u4e00-\u9fa5]{1}[A-Z]{1}[A-Z0-9]{5}$/
3. 身份证号码
var UcUtils = function () {
var Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
var ValideCode = [1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2];
function isTrueValidateCodeBy18IdCard(a_idCard) {
var sum = 0;
if (a_idCard[17].toLowerCase() == 'x') {
a_idCard[17] = 10;
}
for (var i = 0; i < 17; i++) {
sum += Wi[i] * a_idCard[i];
}
valCodePosition = sum % 11;
if (a_idCard[17] == ValideCode[valCodePosition]) {
return true;
} else {
return false;
}
}
function isValidityBrithBy18IdCard(idCard18) {
var year = idCard18.substring(6, 10);
var month = idCard18.substring(10, 12);
var day = idCard18.substring(12, 14);
var temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day));
if (temp_date.getFullYear() != parseFloat(year)
|| temp_date.getMonth() != parseFloat(month) - 1
|| temp_date.getDate() != parseFloat(day)) {
return false;
} else {
return true;
}
}
function isValidityBrithBy15IdCard(idCard15) {
var year = idCard15.substring(6, 8);
var month = idCard15.substring(8, 10);
var day = idCard15.substring(10, 12);
var temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day));
if (temp_date.getYear() != parseFloat(year)
|| temp_date.getMonth() != parseFloat(month) - 1
|| temp_date.getDate() != parseFloat(day)) {
return false;
} else {
return true;
}
}
function trim(str) {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
return {
trimString: function (str) {
return trim(str);
},
isEmpty: function (str) {
return (str === null || str === undefined || str === "");
},
isValidPhoneNumber: function (tel) {
return /^0?1[3|4|5|7|8][0-9]\d{8}$/.test(tel);
},
isValidHphm: function (hphm) {
return /^[\u4e00-\u9fa5]{1}[A-Z]{1}[A-Z0-9]{5}$/.test(hphm);
},
isIdCardValid: function (idCard) {
idCard = trim(idCard.replace(/ /g, ""));
if (idCard.length == 15) {
return isValidityBrithBy15IdCard(idCard);
} else if (idCard.length == 18) {
var a_idCard = idCard.split("");
if (isValidityBrithBy18IdCard(idCard)
&& isTrueValidateCodeBy18IdCard(a_idCard)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
}();