Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BootstrapValidator, validate fields added dynamically to the form

I'm searching for a way to validate fields that I add to a form after the DOM is loaded and $('#formId').bootstrapValidator() is executed. Is there a way to add a new field and validate it when the form is submited?

like image 414
Jairo Avatar asked May 19 '14 16:05

Jairo


2 Answers

I was also searching same thing and found solution HERE

However in my case i have destroy bootstrap obj and reinitialize.

$('#sign-up_area').bootstrapValidator('destroy');
$('#sign-up_area').data('bootstrapValidator', null);
$('#sign-up_area').bootstrapValidator();
like image 125
Muhammad Zeshan Ghafoor Avatar answered Nov 15 '22 08:11

Muhammad Zeshan Ghafoor


There's now a much easier way to accomplish this, using the update method of Bootstrap Validator:

$('#formId').validator('update')

From the docs:

Updates the collection of inputs that will be validated. Call this method if the set of fields which need to be validated has changed.

like image 34
developius Avatar answered Nov 15 '22 07:11

developius