Jquery validation remote rule

Jquery validation remote rule

Hello there,

im have a problem concerning jquery validation using a remote rule.
The value of a text input cant be accesed from within .validate()


part of the html form
  1. ....
  2.             <div class="fieldgroup">
  3.                 <div id=inputs>Username</div>
  4.                     <input type="text" id="UserUsername" name="data[User][username]">
  5.             </div>
  6. ....

jquery validation:
  1. $(document).ready(function() {
  2.     $("#register").validate({
  3.         rules: {
  4.             "data[User][username]": {
  5.                 required: true,
  6.                 minlength: 5,
  7.                 remote: {
  8.                     url: "check_username",
  9.                     data: "username=" + $("#UserUsername").val()
  10.                 }
  11. ...
  12.         },
  13.         messages: {
  14.             "data[User][username]": {
  15.                 required: "Please enter a username",
  16.                 minlength: "Your username must be at least 5 characters long",
  17.                 remote: "Username already taken"
  18.             },
  19. ...
  20.         submitHandler: function(form) {
  21.             form.submit();
  22.         }
  23.     });
  24. });

This creates the following request
  1. http://localhost/pdb_dev_2/users/check_username?username=

The strange thing is although i cant access the element value i can access the element id and name.


The request can be partially fixed with the following remote configuration:
  1.                 remote: {
  2.                     url: "check_username",
  3.                     data: {
  4.                         username: function(){
  5.                             return $("#UserUsername").val();
  6.                         }
  7.                     }
  8.                 }
which generates the following request

  1. http://localhost/pdb_dev_2/users/check_username?data%5BUser%5D%5Busername%5D=asdfasdf&username=asdfasdf
Is it possible, to either remove the parameter which is generated on account to the fieldname or fix the first request?

Any help is appriciated.
Thanks

Regards