Luey
asked on
jquery errorPlacement
I want to be able to append the error message to the label for each input. I also would like to be able to do that to every label and input in my form. I tried this code but it does not work. It appends all the error messages to one label. New to all this ugh!
Thanks
Thanks
<script>
$(document).ready(function(){
$("#commentForm").validate( {
errorPlacement: function (error, element) {
$('#name_label').append(error);
$('#email_label').append(error);
}
});
});
</script>
<label for="name" id="name_label">Name</label>
<em>*</em><input id="name" name="name" size="25" class="required" />
<label for="email" id="email_label">E-Mail</label>
<em>*</em><input id="email" name="email" size="25" class="email required" />
if it contains id of the label field
then replace $('#name_label').append(er ror); with $('#'+element).append(erro r);
then replace $('#name_label').append(er
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works great I just wish I understood it better.
I do not understand your question "But what when the error goes away?"
I do not understand your question "But what when the error goes away?"
is it actual id of the element, or the element (DOM object) itself?