//校验身份证,身份证分为15位和18位
function checkIdCard(obj) {
if ((/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(obj)) || (/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/.test(obj))) {
return true;
}
else {
return false;
}
}
//校验日期日期格式为yyyy-mm-dd
function CheckDateTime(str) {
var pattern = /((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))/;
if (pattern.test(str)) {
return true;
}
else {
return false;
}
}
//校验文本框为纯数字
function CheckNum(str) {
var pattern = /^[0-9]*$/;
if (pattern.test(str)) {
return true;
}
else {
return false;
}
}
时间: 2024-11-06 16:05:50