form validation with jquery and livevalidation

Posted by ImpY on Stack Overflow See other posts from Stack Overflow or by ImpY
Published on 2012-06-02T16:35:00Z Indexed on 2012/06/02 16:41 UTC
Read the original article Hit count: 148

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html