Excluding field by given condition
If your favorite framework is not in the list, you must fill its name in a text box. You can use the callback validator to validate this input:
The logic inside the
callback function is quite simple and easy to understand. The problem comes when you submit the form, the
otherFramework field is marked as valid with a valid icon even if you choose a framework from the list. In that case, the
otherFramework field should be completely ignored.
In order to fix that, we can use the
excluded option provided by the Excluded plugin as following:
TipWhen the field validation is ignored, its container will not have the success class, and the associated icon isn't shown.