Required (error) message not always showing when:
jquery-validate: 1.16.0Error message should this display on first 'empty'
(Error) message visible on second attempt
I think this issue stems from the onfocusout event handler:
onfocusout: function( element ) {
if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) {
this.element( element );
}
},
The call to this.optional( element ) returns either true or 'dependency-mismatch' , so !this.optional( element ) always evaluates to false, which I'm assuming is a bug. The element() check gets skipped tabbing through the form until the element makes it into this.submitted .
I changed the if condition to:
if ( !this.checkable( element ) && ( element.name in this.submitted || this.optional( element )==='dependency-mismatch') ) {
which triggers the element() check as expected for required fields.
Its not clear to me though what 'dependency-mismatch' means so I'm not sure if this the correct (or only) change needed to solve this problem.
Behavior still present in 1.17.0
My required fields are not triggering error state when cleared of their initial value.
edit: After trying a few things, it appears to only be the first validation, once a validation has been triggered other fields DO respond after removing their initial value.
edit2: Fixed for me by adding an $("#inputfield_id").valid(); for a random input, after my $("#form_id").validate();
This issue/proposal has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up.
Thank you for contributing :)
Most helpful comment
I think this issue stems from the onfocusout event handler:
onfocusout: function( element ) {
if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) {
this.element( element );
}
},
The call to this.optional( element ) returns either true or 'dependency-mismatch' , so !this.optional( element ) always evaluates to false, which I'm assuming is a bug. The element() check gets skipped tabbing through the form until the element makes it into this.submitted .
I changed the if condition to:
if ( !this.checkable( element ) && ( element.name in this.submitted || this.optional( element )==='dependency-mismatch') ) {
which triggers the element() check as expected for required fields.
Its not clear to me though what 'dependency-mismatch' means so I'm not sure if this the correct (or only) change needed to solve this problem.