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
- ....
- <div class="fieldgroup">
- <div id=inputs>Username</div>
- <input type="text" id="UserUsername" name="data[User][username]">
- </div>
- ....
jquery validation:
- $(document).ready(function() {
- $("#register").validate({
- rules: {
- "data[User][username]": {
- required: true,
- minlength: 5,
- remote: {
- url: "check_username",
- data: "username=" + $("#UserUsername").val()
- }
- ...
- },
- messages: {
- "data[User][username]": {
- required: "Please enter a username",
- minlength: "Your username must be at least 5 characters long",
- remote: "Username already taken"
- },
- ...
- submitHandler: function(form) {
- form.submit();
- }
- });
- });
This creates the following request
- 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:
- remote: {
- url: "check_username",
- data: {
- username: function(){
- return $("#UserUsername").val();
- }
- }
- }
which generates the following request
- 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