开发者

why is alert box popping out even if I input correct amount of strings/data?

开发者 https://www.devze.com 2023-03-27 22:09 出处:网络
is there something wrong with my validation for the username var ?, i don\'t know why the alert box keeps popping out even if i provided the correct data for username:(

is there something wrong with my validation for the username var ?, i don't know why the alert box keeps popping out even if i provided the correct data for username:(

 i开发者_如何学运维f(userid == ""){
    $( "#dialog:ui-dialog" ).dialog( "destroy" );

    $( "#dialog-confirm" ).dialog({
        resizable: false,
        height: 230,
        width: 350,
        modal: true,
        buttons: {
            "Register": function(){
                $(this).dialog("close");
                $('div#registerpopup').dialog({
                   resizable: false,
                   height: 485,
                   width: 420,
                   modal: true,
                   buttons: {
                        "Register": function(){
                          if(username == "" || username.length < 1 || username.length > 30 ||  username.indexOf(' ') != -1){
                            alert("Username is required\n-should not be less than 1 character\n-not greater than 30 characters\n-It may also not contain spaces");
                            return false;
                          }
                          if(password.length < 7 || password.indexOf(' ') !=  -1 ){
                            alert("Password should not be empty\n-should at least be 7 characters");
                            return false;
                          }
                          if(retypepassword != password){
                            alert("re-type password should be the same as the password!");
                            return false;
                          }
                          if(emailaddress == "" || emailaddress.search(emailRegEx) == -1){
                            alert("Email Address is required and should be a valid email address");
                            return false;
                          }
                          if(secondaryemailaddress != emailaddress){
                            alert("Secondary Email address should be the same as the primary email address!");
                            return false;
                          }
                          if(secretquestion == ""){
                            alert("Secret Question is required!");
                            return false;
                          }
                          if(secretanswer == ""){
                            alert("Secret Answer is required!");
                            return false;
                          }
                          if(reffcode == ""){
                            alert("Reference Code is required!");
                            return false;
                          }
                          $(this).dialog("close");
                        }
                   }
                });
            },
            "Log in": function() {
                $(this).dialog("close");
                $('div#loginpopup').dialog({
                  resizable: false,
                  height: 230,
                  width: 350,
                  modal: true
                })
            }
        }
    });
    return false;
 }


Logic of validation is fine my guess would be you lose or reset username value at same point or don't set it at all.


Just add autoOpen: false to your jQuery UI Dialog.

$('div#loginpopup').dialog({
    autoOpen: false,
    resizable: false,
    height: 230,
    width: 350,
    modal: true
});
0

精彩评论

暂无评论...
验证码 换一张
取 消