Skip to content

ajax field validation with select menu #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ryanm89 opened this issue Aug 30, 2012 · 7 comments
Closed

ajax field validation with select menu #471

ryanm89 opened this issue Aug 30, 2012 · 7 comments

Comments

@ryanm89
Copy link

ryanm89 commented Aug 30, 2012

Do you have any demo's of using ajax field validation with select menus/drop down?

What is happening for me is the ajax call is being made on blur/change and my servlet is returning a proper json message [#id, false, "message"], but the prompt is never displayed, and it doesnt appear that any kind of error is registered. I also put an alert on the hook(per one of your demos) :

$("#formID").bind("jqv.field.result", function(event, field, errorFound, prompText){ console.log(errorFound) })

and that function is not being reached either.

If I change the select menu to an input box everything works as expected. ** The prompt IS displayed and works as expected with AjaxFormValidation **

If you have a working demo of using the ajax field validation on a select or radio , then I will regress to thinking Im doing something wrong. Otherwise, it may be a bug.

@ryanm89
Copy link
Author

ryanm89 commented Aug 30, 2012

just a quick follow up if i put a alertTextLoad: "please wait" on the rule, that does pop up but never goes away.

I get similar behavior out of your demo if I switch the first input to a select in firebug.

@posabsolute
Copy link
Owner

yea it was never intended for selects, it probably is trying to check the value of a select, and it does not exist

@ryanm89
Copy link
Author

ryanm89 commented Aug 31, 2012

Hmm are you sure because the ajax form submit handles the selects perfectly. If I switch the ajaxfield validation to a funcCall that then calls my servlet via ajax that works, but then I run into the "issue'" of it not validating empty fields because required isnt attached.

@posabsolute
Copy link
Owner

hmm will have a look soon

@ryanm89
Copy link
Author

ryanm89 commented Aug 31, 2012

I think the issue is here in the success portion of the _ajax: function(field, rules, i, options)

var errorField = $($("input[id='" + errorFieldId +"']")[0]);
If I switch it to this it works:
var errorField = $($("select[id='" + errorFieldId +"']")[0]);

In the form method you have:
// var errorField = $($("#" + errorFieldId)[0]) .... this works for ajaxFormValidation but not for field, I dont know the code well enough to speculate why that is(its even commented out under the ajaxFieldVal)

@ryanm89
Copy link
Author

ryanm89 commented Sep 1, 2012

So this is the fix I've found , on line 1324

change:
var errorField = $($("input[id='" + errorFieldId +"']")[0]);

to:
var errorField = $($("[id='" + errorFieldId +"']")[0]);

I have not tested extensively, but this seems to work for all input types (box, select, radio).

@posabsolute
Copy link
Owner

thanks, make sense,

I think :input works too, but im not sure about this line, it strange, it should be $("#"+ errorFieldId).eq(0) or something like that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants