Search code examples
javascripthtmljqueryjquery-validation-engine

adding new Input to jquery validationEngine form?


I have some fairly complex ajax logic etc going on in the onValidationComplete function for a form with jQuery Validation Engine.

This is working perfect, but one thing is bothering me.

in the form I have the ability to dynamically add inputs (add new row button).

so my code structure wise looks like:

var form = $('#myForm');

form.validationEngine('attach', {onValidationComplete:validationComplete});
$('#newInput').on('click', function(){
    form.append('<input />');
    form.validationEngine('detach');
    form.validationEngine('attach', {onValidationComplete:validationComplete});
});

function validationComplete(form, status){/*all my logic here*/}

What I don't like about it is that every time I add a new input I have to detach and then re-attach the validationEngine.

Is there any way to just tell it to add the new input to it's list of inputs to validate?


Solution

  • Have you tried using .on() method?