jquery multiple datepicker clear altformat date question

jquery multiple datepicker clear altformat date question

Assuming this "feature" still exists whereby if you clear a date on a datepicker input, the alformat date is not cleared.

I have the following script and if an input date field is removed/cleared, the altformat date remains and is not cleared. Is there a known way that works to also clear the alformat date when the input date is cleared? I suspect

  1. if (!$(this).val()) $("#" + $(this).data('target-id').val('');

could be a start, but where and how is getting me stuck.
  1. $(function() { $('.display_date').each(function(){ $(this).datepicker({ minDate: +0, constrainInput: false, changeMonth:true, changeYear:true, yearRange:"-1:+3", dateFormat: "d MM yy", altField: "#" + $(this).data('target-id'), altFormat: "yymmdd" }); }); <form method="post" action=""> Close Display Date : <input class="display_date" data-target-id="closedate" type="text" readonly/> Hidden real ClosealtField : <input type="text" id="closedate" value="" /> Draw Display Date : <input class="display_date" data-target-id="drawdate" type="text" value="" /> Hidden real DrawaltField : <input type="text" id="drawdate" value="" /> </form>