datepicker.ui + validate plugin -- triggers 'invalid' when date 1st picked
I'm using the datepicker.ui in a form that also uses the validate plugin. The form happens to use the accordion functionality
found here, but I've also tested this in a simpler form that uses the standard syntax for both scripts.
When the user initially picks a date using the datepicker, validate runs and flags the input as invalid, even 'though the field
is valid. choosing another date, or choosing the date a second time, sets the field to valid. Simplified HTML:
- <label for="datepicker">Date</label>
- <input name="datepicker" class="datepicker pageRequired date" type="text" value="Click Me!" />
and JavaScript excerpt, minus some accordion stuff:
- $.validator.addMethod("pageRequired", function(value, element) {
- var $element = $(element)
- function match(index) {
- return current == index && $(element).parents("#sf" + (index + 1)).length;
- }
- if (match(0) || match(1) || match(2) || match(3) || match(4)) {
- return !this.optional(element);
- }
- return "dependency-mismatch";
- }, $.validator.messages.required)
- var v = $("#order-form").validate({
- submitHandler: function() {
- alert("Submitted, thanks!");
- }
- });
I'm still pretty new to JS & jQuery, so any answers may need to be spelled out pretty explicitly.
Thanks for your interest,
--cz