Thursday, 19 September 2013

jQuery: Hide a field and mark it as valid

jQuery: Hide a field and mark it as valid

I have the following scenario:
I have a radio-group that hides or shows some input fields onchange which
works fine:
view.selectFormerHRInsurance.change(function() {
if ($(this).val() == true) {
view.sectionHRInsuranceName.show();
view.sectionHRInsuranceNumber.show();
view.sectionHRInsuranceSum.show();
view.sectionHRInsuranceStatus.show();
view.sectionHRInsuranceTerminationDate.show();
} else {
view.sectionHRInsuranceName.hide();
view.sectionHRInsuranceNumber.hide();
view.sectionHRInsuranceSum.hide();
view.sectionHRInsuranceStatus.hide();
view.sectionHRInsuranceTerminationDate.hide();
}
});
When a field is validated and there is an error, the error message appears
on the field and i show a global error message.
My problem is, that the global error message is still present, when i hide
the fields and as you can guess: i don't want that!
I want to "mark" the fields i hide as validated and validate it, when i
show them. How can i achieve this?

No comments:

Post a Comment