why is alert box popping out even if I input correct amount of strings/data?
<p>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:( </p>

<pre><code> if(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 &lt; 1 || username.length &gt; 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 &lt; 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;
 }
</code></pre>
