日期:2014-05-17  浏览次数:20891 次

怎么能够控制注册提交??!!小弟百拜跪谢高手!!!
我写检验用户信息输入是否填写完整的方法实现。
我是这么做的,先是每个信息输入的时候有合法性的判断,分别为function a ,b,c,方法都用的是返回真或假,
在最后为了防止必要信息填写不完整,我就写了一个再次检验前面方法 A ,如下:
 
JScript code

  function regCheck()
    {
        check_UserName();
        if(!check_UserName_bool || $("text_UserName").value =="")
        {
            $("text_UserName").focus();
            return false;
        }
        
              
        check_UserPWD1();
        if(!check_UserPWD1_bool|| $("text_UserPWD1").value =="")
        {
            $("text_UserPWD1").focus();
            return false;
        }
        
        check_UserPWD2();
        if(!check_UserPWD2_bool)
        {
            $("text_UserPWD2").focus();
            return false;
        }
        
              alert("验证时 Email:" + check_UserName_bool);
        if(!check_UserEmail_bool || $("text_UserEmail").value =="")
        {
            $("text_UserEmail").focus();
            return false;
        }
        
         check_ValidCode();
         if(!check_ValidCode_bool)
         {
             $("text_ValidCode").focus();
             return false;
         }
         
        
         return true;
         
     }


整个代码应该逻辑没有问题。
我在页面画了个提交按钮,
 <input type="image" name="ImageButton1" id="ImageButton1" src="/images/register.gif" onclick="return regCheck();" style="border-width:0px;" />

我本来想的是如果方法regCheck返回为真,也就是所有的信息都填玩了才能提交信息,但是目前却变成了,它每次只检验第一个也就是用户名是否输入,如果只填一个用户名,就点击按钮,它就提交了。。。。。。。不知道这里该怎么弄呢??
小弟百拜跪谢,各位哥哥还望给力啊!!!!

------解决方案--------------------
是不是 check_UserName(); 就return ture 了 ?

------解决方案--------------------
function regCheck()
{
if(!check_UserName_bool || $("text_UserName").value =="")
{
$("text_UserName").focus();
return false;
}
else if(!check_UserPWD1_bool|| $("text_UserPWD1").value ==""){
$("text_UserPWD1").focus();
return false;
}else if(!check_UserPWD2_bool){
$("text_UserPWD2").focus();
return false;

}else if(!check_UserEmail_bool || $("text_UserEmail").value ==""){
 $("text_UserEmail").focus();
return false;

}else if("!check_ValidCode_bool"){
$("text_ValidCode").focus();
return false;

}else {
return true
}你的代码出在逻辑上的问题

------解决方案--------------------
把提交按钮换成button 点button的触发onclick时间 在 document.表单name.submit(); 就是把表单提交放在最后的else里