Bug #7091
closedjQuery Validate: required field validation unreliable
Description
This is due to a bug in jQuery Validate it self as reported below.
https://github.com/jquery-validation/jquery-validation/issues/1975
The validation only kicks in after another validation rule has been applied then all required validation works as normally.
Updated by krileon over 6 years ago
Either wait for new release of jQuery Validate to fix or try to implement a potential workaround. Likely some sort of add caching behavior for validation rules.
Updated by krileon over 6 years ago
Cause appears to be ! this.optional( element )
usages through jQuery Validate. The optional function will either return false, true, or dependency-mismatch so using the above condition doesn't work due to this as dependency-mismatch would cause that condition to fail.
Updated by krileon over 6 years ago
It's due to the wrong order of validation rules, but that's due to $( element ).rules()
not being called until after another validation rule has triggered which fixes the order so required rules are first and remote rules are last. Maybe the order can be fixed externally instead of relying on that function?
Updated by krileon over 6 years ago
- Status changed from Assigned to Resolved
- % Done changed from 0 to 100
Fixed in MR !1325 with workaround of checking that ( this.optional( element ) !== true )
to treat false and dependency-mismatch as validation needs to be triggered.