views:

508

answers:

4

I have the jQuery UI Datepicker and the bassistance.de validation plugin working except for one problem. When a date is selected with the date picker, it causes a validation error even though the date is correct. I have tried it on different sites and I get the same problem. It doesn't cause a validation error when you click submit.

+1  A: 

I think I found the answer. The problem is that the jQuery validation plugin is validating on the click, keyup, or onfocusout event. Not sure which one. I just disable these so it would only do it on submit which looks cleaner for my implementation anyway.

These are the values I set to false:

onfocusout: false, onkeyup: false, onclick: false

vincentw56
A: 

I just had the same problem!

Vicent, your solution works! Thanks

André Luiz
A: 

Thanks Vincent,

You're a life saver...

Fadi
+1  A: 

I had this problem when I used the datepicker with default settings.

When I stepped through, it looked like the issue is validation gets called when you select a new date on the picker, but gets passed the existing value, not the one you've just selected.

After the picker closes, you're no longer in the input, so the validation doesn't fire again, meaning it never gets called with the correct value.

Using a button and the fix at http://stackoverflow.com/questions/1401917/jquery-ui-datepicker-loses-focus-when-selecting-date-with-mouse/1401978#1401978 I was able to get the two playing nicely together. That is, after selecting a new date, the focus is still on the date input, and tabbing/clicking out causes validation to fire correctly.

David