0

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.

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 > 30)
{

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

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

};

any help would be appreciated

2
  • hey you could take a look at this: digitalbush.com/projects/masked-input-plugin Commented Aug 31, 2011 at 11:24
  • @meo - thanks for that link...very useful to know Commented Aug 31, 2011 at 11:44

1 Answer 1

1

If #departure is a text input element, you should edit their value this way:

document.getElementById('departure').value= 'hey';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.