If you want to reuse the behaviour in this example,
take a look at the
mandatoryIcon add-on.
As you know, the FormValidation provides three feedback
icons which are shown based on the status of field:
Setting |
Description |
icon.valid |
Shown when the field is valid |
icon.invalid |
Shown when the field is invalid |
icon.validating |
Shown when the field is being validated |
In this example, you will see how to show a required icons if the field is mandatory.
The setting will look like as following:
The implementation uses:
- getOptions() method to get the required icon option
- Show the required icons by triggering the init.field.fv event which is called after the field
is initialized by the plugin
- Hide the required icons by triggering the status.field.fv event which is called after the
field changes its status
If the form uses different input types which might cause
the required icon not shown properly, you can
adjust its position.