form validation with jquery and livevalidation
- by ImpY
I'm trying to do some form validation with livevaldation & jquery.
I've a formular with an input field like that:
<div id="prenameDiv" class="control-group">
`<input id="prename" name="prename" class="input-large" placeholder="Max" >`
</div>
So if there's an error on validation 'livevalidaton' adds the class 'LV_invalid_field' to the input - it looks like that:
<div id="prenameDiv" class="control-group">
<input id="prename" name="prename" class="input-large LV_invalid_field" placeholder="Max" >
</div>
That's ok, but now I'll add another class 'error' to the div 'prenameDiv' when the DOM changes that it looks like that:
<div id="prenameDiv" class="control-group error">
`<input id="prename" name="prename" class="input-large LV_invalid_field"
placeholder="Max" `
</div>
I tried it that way:
if ($("#prenameDiv").bind("DOMSubtreeModified")){
`if ($("#prename").hasClass("LV_invalid_field")) {`
$("#prenameDiv").addClass("error");
}
}
But nothing changes? Do you have some ideas?