JS正则验证

var bo=/^(\d{6})(18|19|20)?(\d{2})([01]\d)([0123]\d)(\d{3})(\d|X)?$/.test(member_idcard);
if(bo == true){

  var year = member_idcard. substr(6,4);
  var month = member_idcard. substr(10,2);
  var day = member_idcard. substr(12,2);
}

if(member_idcard && (bo==false||month>12||day>31)){

  alert("身份证号码不正确");
}



if(member_email && !member_email.match(/\w+@\w+\.\w+/ig)){

  alert("邮箱地址不正确");

}


var dateNow = new Date();
if(birthday > dateNow){

  alert("出生日期不正确");
}



if(member_mobile && !member_mobile.match(/1[3|4|5|7|8][0-9]{9}$/ig)){

  alert("手机号码不正确");
}


 
  

你可能感兴趣的:(java,js)