<form action="suiji.html" return onsubmit="sumDat()">
<tr>
<td><input type="submit" value="提交" onckick="sumDat()" /></td>
</tr>
</table>
</form>
</body>
</html>
<script>
function checkMail(){
var mail=document.getElementById("mail").value;
var emailMag=document.getElementById("emailMag");
var reg=/^[a-zA-Z]{1}[\w]{5,15}$;
if(mail==""){
emailMag.innerHTML="用户名不能为空";
return false;
}else if(reg.test(mail)){
emailMag.innerHTML="首字母大写";
return true;
}else{
emailMag.innerHTML="开头母必须为字母";
return false;
}
}
function checkage(){
var age=Number(document.getElementById("age").value);
var ageMag=document.getElementById("ageMag");
if(age==""){
ageMag.innerHTML="岁数不能为空";
return false;
}else if(age<1){
ageMag.innerHTML="岁数不能小于1,";
return false;
}else if(age>100){
ageMag.innerHTML="岁数不能大于100"
}else{
return true;
}
}
function checkDate(){
var use=document.getElementById("use").value;
var date=document.getElementById("date");
var regDate=/^((19[0-9]{2})|(200[0-9]{1})|(201[0-7]{1}))((0[1-9]{1})|(1[0-2]{1}))((0[1-9]{1})|[1-2]{1}[0-9]{1}|3[0-1]{1})$/;
if(use==""){
date.innerHTML="不能为空";
return false;
}else if(regDate.test(use)){
var year=use.substr(0,4);
var month1=use.substring(4,6);
var day=use.substring(6,8);
document.getElementById("pwd").value=year;
document.getElementById("qpwd").value=month1;
document.getElementById("day").value=day;
return true;
}else{
date.innerHTML="输入年份不对";
return false;
}
}
function sumDat(){
if(checkMail()&&checkage()){
return true;
}else{
return false;
}
}
</script>