Check if input,select has value after ajax submit and if not null/empty hide label

Check if input,select has value after ajax submit and if not null/empty hide label

I have a multi-part form which is a CMS plugin I prefer not to hack.  I am using absolute positioning for the labels to appear inside (over) each input and select elements.

The following code works great for focus and blur events at any stage of the form but once the first step is submitted, any returns to the previous step(s) retain the values and result in both the label and value being present.

I need to find a way to hide the labels if values are present but I'm not sure how or if I can do this without modifying the plugins code that perfoms the callback.

  1. //show hide form labels/descriptions on focus
  2. jQuery('#simple-form').on({
  3. focus: function(){
  4. jQuery(this).parent().siblings("label").hide();
  5. jQuery(this).parent().next('.gfield_description').fadeIn(500);
  6. },
  7. blur: function(){
  8. // hide or show the label based on whether we have values in the field
  9. jQuery(this).parent().siblings("label")[!this.value ? 'show' : 'hide']();
  10. jQuery(this).parent().next('.gfield_description').fadeOut(100);
  11. }},'input, select');