jQuery validation plugin: show hide label / existing labels
Hey guys,
maybe some one can help me out. I have a working registration form and now i want to add this wonderful jquery form valitation plugin to validate the user input before sending the form.
So far so good all is working and btw. it was easy to setup even for some one with very poor js skill.
My question is now: can i hide the label for the input fields and dropdowns, i mean the labels i have in the form - not the error labels created by the jquery form valitation plugin, when the jquery generated labels appear? Like a switch show the default labels when no error and hide if an error?
-
<script type="text/javascript">
$(document).ready(function() {
$("#formular").validate({
meta: "validate",
errorClass: "jqerror",
invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
$("label").hide();
} else {
$("label").show();
}
}
});
});
</script>
When i use this code, then on submit / on error all the labels are gone because it hides all the labels. So far i understand my own code but i have no idead how to manage to just hide specific labels, the labels with errors? I took a look into the jquery.validate.js file and found on line 596 the "showLabel" function. Maybe i have to rewrite this one but as i wrote before: i have no idea where to start.
Thanks for any help in advance!