日期:2014-05-16  浏览次数:20365 次

高手请帮忙呀!!!我用Javascript验证注册页面,可就是怎么已不能验证通过!!!小弟刚学!!!
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN "
"http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 无标题文档 </title>
<script   language= "javascript ">
/*function   checkUserName()
{
var   username=documnt.myform.txtUserName.value;
if(username== " ")
{ window.alert( "kk ");
alert( "用户名不能为空! ");
document.myform.txtUserName.focus();

}
}*/
function   CheckRegister()
{
var   username=document.myform.txtUserName;
var   pass1=document.Form1.txtPassword;
var   pass2=document.Form1.txtPwd;
var   name=document.Form1.txtName;
var   email=document.Form1.txtEmail;
var   addr=document.Form1.txtAddress;
var   handno=document.Form1.txtHandsetNo;              
if(username.value== " ")
{
alert( "用户名不能为空! ");
document.myform.txtUserName.focus();
return   ;
}
if(name.length== " ")
{
alert( "联系人不能为空! ");
document.myform.txtName.focus();
return   ;
}
if(handno.length==0)
{
alert( "常用号码不能为空! ");
document.myform.txtHandsetNo.focus();
return   ;
}
if(addr.value== " ")
{
alert( "地址不能为空! ");
document.myform.txtAddress.focus();
return   ;
}
if(email.length==0)
{
alert( "Email不能为空! ");
document.myform.txtEmail.focus();
return   ;
}
if(email.indexOf( "@ ",0)==-1)
{
alert( "Email格式不正确!\n必须包含@符号! ");
document.myform.txtEmail.focus();
return   ;
}
if(email.indexOf( ". ",0)==-1)
{
alert( "Email格式不正确!\n必须包含.符号! ");
document.myform.txtEmail.focus();
return   ;
}
if(pass1.value==pass2.value)
{
if(pass1.length!=0)
{
return   true;
}
else
{
alert( "维护密码不能为空! ");
document.myform.txtPassword.focus();
return   ;
}
}
else
{
alert( "确认密码必须与维护密码相同! ");
document.myform.txtPwd.focus();
return   ;
}
}
</script>
</head>

<body>
<form   name= "myform "   method= "post "   action= " ">
    <table   width= "597 "   height= "219 "   border= "1 "   align= "center ">
        <tr>
            <td   width= "79 "> 用户名: </td>
            <td   width= "158 "> <input   name= "txtUserName "   type= "text "   size= "13 ">