...

View Full Version : date input calendar help??



naim
04-22-2008, 08:29 AM
Hello,
I have to include a calendar in my script that will POST selected date.I have
downloaded jason moons calendar script.The problem is I want all the previous
dates from todays date should disabled, ie- user can not select yesterdays any date. What modifications could be done? or there is a javascript which has all
the features i'm looking for? Help me..
Thanks!
Naim

Philip M
04-22-2008, 08:48 AM
You need to add a script something like this:-

<script type = "text/javascript">

function checkDate() {
var now = new Date().getTime();
var d = new Date();
d.setFullYear(2008,3,22); // Selected date in format YYYY,MM(0-11),DD
var selectedDate = d.getTime();
if (selectedDate < now) {
alert ("Selected date cannot be before today's date!")
return false;
}
return true;
}

</script>

It is your responsibility to die() if necessary….. - PHP Manual

naim
04-22-2008, 09:07 AM
Thats OK philip but if all yesterdays dates automatically get disabled then the procedure will
be much easy. I am looking for this type of solution ie- user only be able to select todays OR next dates only. Any solution philip ??

Philip M
04-22-2008, 11:27 AM
In fact Moon offers the following:-

<
script>DateInput('someDate', true)</script>

- - -

<script>
function validateTheDate() {
var Today = new Date();
if (someDate_Object.picked.date < Today) alert('Cannot select a date in the past.');
else if (someDate_Object.picked.yearValue > 2020) alert('Cannot select dates beyond 2020.');
}
</script>


If you mean that past dates cannot be displayed at all in the select option lists, then I don't see this as practcal, although it mightbe possible with a great deal of code. Not worth the effort in my view.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum