SO fiddle

Test Fiddle mainly for SO Questions

by Nick Craver

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/overcast/jquery-ui.css">
<div>
<p>Date: <input type="text" class="datepicker">&nbsp;<input type="text" class="datepickeralt" size="30"/></p>
</div>
<div>
<p>Date: <input type="text" class="datepicker">&nbsp;<input type="text" class="datepickeralt" size="30"/></p>
</div>
<div>
<p>Date: <input type="text" class="datepicker">&nbsp;<input type="text" class="datepickeralt" size="30"/></p>
</div>

CSS

div { padding: 10px; }

JavaScript

$('.datepicker').each(function() {
  $(this).datepicker({
    altField: $(this).closest('div').find('.datepickeralt')
  });
});