In some cases, you might want to validate given fields while ignoring validation on other one. Let's look at the following particular case:
The signing in form defines validator rules for the username and password fields
There's also a modal that allows user to enter the email address in case he wants to reset the password
The main form and modal have separated submit buttons.
Clicking the Submit button in the main form only validates the username/password fields
And vice versa, clicking the Submit button in the modal will trigger the validations on the email field only
The requirement above can be easily implemented if we put the main form and modal into separated forms. By doing that, clicking the Submit button in each form doesn't effect to the validations of the other one. The problem is solved.
But, what if the page always has only one form, such as the master page from ASP.Net.
This example shows you a way to solve this again by using two powerful features of FormValidation:
Initially, all the validators of email field are disabled via the enabled option
When showing the modal, we can turn them on via the enableFieldValidators() method. Also, they are turned off when closing the modal.
The Bootstrap modal provides shown.bs.modal and hidden.bs.modal event that are triggered after showing/hiding a modal. That are the places where we can toggle the field validations.
You can take a look at the Programmatic code tab to see the full working code.