用javascript怎么验证注册信息?

来源:百度知道 编辑:UC知道 时间:2024/06/27 18:20:13
form表单的名字是fm,用户名的名字是name,密码是psw,确认密码是psw1,E-mail是email
具体要求是这样的,都写在function check()里
1,用户名不能为空,否则alert()...
2,密码必须大于6位,否则alert()...
3,确认密码要和密码一致,否则alert()...
4,email必须符合相应格式a@b.c,否则alert()...

谢谢了,!!!

function check(){
var webname = document.fm.name.value;
var password = document.fm.psw.value;
var password_copy = document.fm.psw1.value;
var uemail = document.fm.email.value;

if(webname == null || webname == ''){
window.alert("请填写用户名");
return;
}
if(password == null || password == ''){
window.alert("请设定密码");
return;
}
if(password_copy == null || password_copy == ''){
window.alert("请再次输入密码");
return;
}
if( password !=password_copy){
window.alert("两次输入的密码不一样");
return;
}
if(password.length < 6){
window.alert("密码长度不小于6字符");
return;
}
if(uemail == null||uemail ==''){
window.alert("请输入Email");
return;
}
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.&#