用户注册校验123

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<scripttype="text/javascript">
functionsave(){
varusername = document.getElementById("username");
if(username.value ==""){
alert("用户名不能为空!");
returnfalse;
}
varpassword = document.getElementById("password");
if(password.value ==""){
alert("密码不能为空!");
returnfalse;
}
varrepassword = document.getElementById("repassword");
if(repassword.value ==""){
alert("确认密码不能为空!");
returnfalse;
}
if(password.value != repassword.value){
alert("两次输入密码不一致!");
returnfalse;
}
varage = document.getElementById("age");
if(age.value ==""){
alert("年龄不能为空!");
returnfalse;
}
if(isNaN(age.value)){
alert("年龄为数字!");
returnfalse;
}
}
</script>