From 4342f28e800eaf33302cea06ab25839e18ce353b Mon Sep 17 00:00:00 2001 From: rjy7 Date: Fri, 3 Sep 2010 19:32:34 +0000 Subject: [PATCH] NIHVIVO-1024 When returning from validation error in educational background form (and roles form in repair mode), hide org name validation error if org name field is hidden. --- webapp/web/js/customFormUtils.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/webapp/web/js/customFormUtils.js b/webapp/web/js/customFormUtils.js index c0b0f1b43..edd4564bf 100644 --- a/webapp/web/js/customFormUtils.js +++ b/webapp/web/js/customFormUtils.js @@ -22,19 +22,22 @@ vitro.customFormUtils = { // This method should always be called instead of calling hide() directly on any // element containing form fields. hideFields: function(el) { - // Clear any input and error message, so if we re-show the element it won't still be there. + // Clear any input and error messages, so if we re-show the element it won't still be there. this.clearFields(el); el.hide(); }, // Clear data from form elements in element el clearFields: function(el) { - el.find(':input[type!="hidden"][type!="submit"][type!="button"]').val(''); - - // For now we can remove the error elements. Later we may include them in - // the markup, for customized positioning, in which case we will empty them - // but not remove them here. See findValidationErrors(). - el.find('.validationError').remove(); + el.find(':input[type!="hidden"][type!="submit"][type!="button"]').each(function() { + $(this).val(); + // Remove a validation error associated with this element. + // For now we can remove the error elements. Later we may include them in + // the markup, for customized positioning, in which case we will empty them + // but not remove them here. See findValidationErrors(). + $('*[id=' + $(this).attr('id') + '_validationError]').remove(); + }); + }, // Return true iff there are validation errors on the form