Thanks for the earlier tip.
I have changed the goalposts a little bit and am doing some extra stuff.
I have removed the onblur call from the CopyValue function and added it to a datepicker1 change function, so that the date is updated as before, and also the minDate for the 'dateto' field is set to be the same as the datefrom field, so the user cannot set a dateto which is earlier than date from.
so far so good.
What i can't get to work is adding a condition so that the dateto field is updated ONLY if it is currently empty, so if both fields have a value and the user decides to change the datefrom value, the dateto value is not affected.
here is my function as it stands...
$("#datepicker_1").change(
function() {
var test = $(this).datepicker('getDate');
var test2 = new Date(test.getTime());
test2.setDate(test2.getDate());
$("#datepicker_2").datepicker("option", "minDate", test2);
CopyValue('datepicker_1','datepicker_2');
});
i tried to update the CopyValue function like so...
if(document.getElementById("datepicker_1").value = "") {
** do the update**
}
but it doesn't work.