0

I have create my own Bootstrap validator:

$('.myValidatorClass').validator({          
    custom: {             
         'datainizio':function($el){
             return dataInizio($el);                         
         }             
    },
    errors: {
        datainizio: "error"
    }}).on('submit', function (e) {        
        // code                 
      }
    })

The method dataInizio() check if a "start date" field is filled when a "end date" field is filled; it works.

this is the end date field:

<input id="endDate" nama="endDate" data-datainizio="datainizio" />
<div class="help-block with-errors"></div>

Now, I need to programmatically (I suppose) call the validator when the value of the "start date" field changes, in order to remove the errore message in the form.

I read this page, and used $("#form").validator('validate'), but the error messages are not deleted on the page. It seems Bootstrap validator calls only its own "validation methods" and not also my "validation methods" like datainizio

Thank you in advance.

Jeroen
  • 1,168
  • 1
  • 12
  • 24
MDP
  • 4,177
  • 21
  • 63
  • 119
  • The Bootstrap Validation plugin and the jQuery Validate plugin are not the same thing. Edited tags. Thanks. – Sparky Jul 18 '16 at 17:40
  • Sorry, but your answer is not clear to me. What you mean? – MDP Jul 20 '16 at 08:54
  • It's not an answer. It's a comment. I meant that you *incorrectly* tagged your question with the jQuery Validate plugin. – Sparky Jul 20 '16 at 14:22

2 Answers2

3

use code bellow

$("#form")[0].checkValidity();

it return true false and simply check it out. Good luck

vahid sabet
  • 485
  • 1
  • 6
  • 16
0

if your form is coming dynamically ,so PLEASE use "jQuery" in place of "$"

jQuery('.myValidatorClass').validator({          
    custom: {             
         'datainizio':function(jQuery el){
             return dataInizio(jQuery el);                         
         }             
    },
    errors: {
        datainizio: "error"
    }}).on('submit', function (e) {        
        // code                 
      }
    })

Please let me know if see any issue :)