adding new Input to jquery validationEngine form?

Posted by Hailwood on Stack Overflow See other posts from Stack Overflow or by Hailwood
Published on 2012-11-04T10:36:43Z Indexed on 2012/11/04 10:59 UTC
Read the original article Hit count: 217

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?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery