javascript force date into input field
<p>i have 2 input fields for a check in date and a check out date. when the user puts in the dates it calculates the nights. However i dont want the user to be able to put a date 30 days after the check in date. Ive used an alert to bring up a message if nights is greater then 30 however the date u selected goes into the check out date. Im trying to use innerHTML to force the date in the check out to be what i want it to be ie 1 day after the check in date if they have selected more then 30 days. Heres part of my code.</p>

<pre><code>function DoDepart() {

Date.fromUKFormat = function(sUK)
{
    var A = sUK.split(/[\\\/]/);
    A = [A[1],A[0],A[2]];
    return new Date(Date.parse(A.join('/')));
}

var a = Date.fromUKFormat(document.getElementById('datepicker').value);
var b = Date.fromUKFormat(document.getElementById('departure').value);
var x = ((b - a) / (24*60*60*1000));

if (x &gt; 30)
{

alert("check out date must be within 30 days of your check in date");
document.getElementById('departure').innerHTML = 'hey';&lt;!--this bit must be wrong
}

document.getElementById('n').value = x; 

};
</code></pre>

<p>any help would be appreciated</p>
