problem with validation plugin and request

problem with validation plugin and request

i want to get a script which checks the databes for existing usernames.
but in fact it does nothing, it even buggs:
 when typing a username with 2 characters (error: "Enter at least 3 characters" - which is actually okay)
and then inserting a 3rd or more characters the error message does not dissapear, you can't send the form.
when you type a correct username instant, the script works.
i have no idea whats wrong.

code following:
  1. $("#signupform").validate({
            rules: {
                username: {
                    required: true,
                    maxlength: 20,
                    minlength: 3,
                    remote: {
                        url: "user.php",
                        type: "post",
                      },
                 },                
                firstname: "required",
                lastname: "required",
     
                addr1: {
                    required: true,
                    minlength: 5
                },
                plz: {
                    required: true,
                    minlength: 4,
                    number: true
                },
                city: {
                    required: true,
                    minlength: 2
                },
                country: {
                    required: true,
                    minlength: 3
                },
                email: {
                    required: true,
                    email: true
                },
                phone: {
                    number: true
                },
                pwb: {
                    required: true,
                    minlength: 5,
                    equalTo: "#pwa"
                },
                pwa: {
                    required: true,
                    minlength: 3
                }
            
            },
            messages: {
                firstname: {
                    required: "Please enter your first name.",
                    minlength: "Your first name must consist of at least 3 characters"
                },
                lastname: {
                    required: "Please enter your last name.",
                    minlength: "Your last name must consist of at least 3 characters"
                },
                username: {
                    required: "Enter a username",
                    minlength: "Enter at least 3 characters",
                    remote: jQuery.format("{0} is already in use")
                },
                pwa: {
                    required: "Please provide a password",
                    minlength: "Your password must be at least 5 characters long"
                },
                pwb: {
                    required: "Please provide a password",
                    minlength: "Your password must be at least 5 characters long",
                    equalTo: "Please enter the same password as above"
                },
                email: "Please enter a valid email address"
            }
        });
    });











































































  1. <?php
    include ("php/sql.php")
    $temp = mysql_query("select * from shop_User");
    $request = trim(strtolower($_POST[username]));
    $valid = 'true';

    while ($a = mysql_fetch_array($temp)) {
        if($request == $a[user] ) {
            $valid = 'false';
        }
    }
    echo $valid;
    ?>













thanks for your help!