jQuery Validation username check (DB)

jQuery Validation username check (DB)

Hi,
I was building a user registration form using jQuery Validation and I thought that it should have a user-name validation check...
This not that difficult to make however the examples I found is based on simple forms with submit type buttons. The thing is that I forced validation to be triggered when a simple button type object is clicked, so I am not shure if the same codes I found will do...
How ever I do not cope with the side of user-name checking...
Here is my username-check.php
  1. <?php
  2. include 'connect.php';
  3. $name = mysql_real_escape_string($name);
  4. $query = "SELECT user_name FROM users WHERE user_name='$name';";
  5. $res = mysql_query($query);
  6. if (mysql_num_rows($res) > 0) {
  7.     $output = true;
  8. } else {
  9.     $output = false;
  10. }
  11. echo json_encode($output);
  12. ?>
Now here is some js snipets
  1.       //in rules
  2.             username: {
  3.         required: true,
  4.         minlenght: 6,
  5.         remote: "check-username.php"
  6.         },
  7.     //in  messages
  8.             username: {
  9.                 required: "Please enter a username",
  10.                 minlength: "Your username must consist of at least 6 characters",
  11.                 remote: "Somenoe have already chosen nick like this."
  12.             },
and result I get...
  1. $.validator.methods[method] is undefined
  2. (function($){$.extend($.fn,{validate:f...ed when checking element "+element.id
    jquery....min.js (line 15)

any help?