/^([0-9a-zA-Z]+[_.0-9a-zA-Z-]*)@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/
/^((13[0-9])|(15[0-9])|(18[0-9])|(14[0-9])|(17[0-9])|(199)|(198)|(166))[0-9]{8}$/
/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/ #8到16位字母和数字的组合
/((http|https):\/\/([\w\-]+\.)+[\w\-]+(\/[\w\u4e00-\u9fa5\-\.\/?\@\%\!\&=\+\~\:\#\;\,]*)?)/
/^[\u4E00-\u9FA5]+$/ #姓名必须必须为汉字
/^[\u4E00-\u9FA5]{2,8}$/ #姓名必须为2到8个汉字
/^\d{4}$/ #四位
/^\d{6}$/ #六位
function validate_id(id){
if(id.match(/^\d{6}(19|20)\d{2}[01]\d{1}[0-3]\d{1}(\d{4}|\d{3}x)$/i)){
var weight = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
var checkCode = [1, 0, 'x', 9, 8, 7, 6, 5, 4, 3, 2];
var s = 0;
for(var i=0; i<17; i++){
s += id.substr(i, 1) * weight[i];
}
if(checkCode[s%11] != id.substr(17, 1).toLowerCase( )) {
alert('身份证号不正确');
return false;
}
var year = parseInt(id.substr(6,4),10);
var month = parseInt(id.substr(10,2),10);
var day = parseInt(id.substr(12,2),10);
var date=new Date(month + '/' + day + '/' + year);
if(date.getFullYear()!=year || date.getDate()!=day || date.getMonth()!=(month-1)){
alert('身份证号不正确');
return false;
}
}else if(id.match(/^\d{6}\d{2}[01]\d{1}[0-3]\d{1}(\d{3}|\d{2}x)$/i)){
var year = parseInt('19'+id.substr(6,2),10);
var month = parseInt(id.substr(8,2),10);
var day = parseInt(id.substr(10,2),10);
var date=new Date(month + '/' + day + '/' + year);
if(date.getFullYear()!=year || date.getDate()!=day || date.getMonth()!=(month-1))
{
alert('身份证号不正确');
return false;
}
}else{
alert('身份证号不正确');
return false;
}
}
var str = '18811408557';
var reg = /^([0-9a-zA-Z]+[_.0-9a-zA-Z-]*)@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/;
if(reg.test(str)){
return true;
}else{
return false;
}