hey all
i have 3 drop down boxes: one for the day, month and then the year. however i'd like to have it so that the person choosing the date can't choose a past date. In other words if they try choose for instance the 14th Oct when it's now the 17th Oct, The value selected should not be anything less than the 17th Oct...
there is a little Javascript for sending a msg if the dates are in the past however i can't get the selected date to remain the present date...
<script>
function isValidDate()
{
var now = new Date();
//advance one day
now.setDate( now.getDate() - 1 );
var Day=document.getElementById('daysOfMonth').value;
var Month=document.getElementById('monthOfYear').value;
var Year=document.getElementById('year').value;
var str = Month + " " + Day + " " + Year;
var selectedDate= new Date(str);
if(selectedDate < now)
{
alert("You may not select dates in the past . . . only future days!!!");
}
}
</script>
<form action="AvailableRooms.php" method="post" name="CheckAvailability" target="_self" id="CheckAvailability">
<label for="daysOfMonth"></label>
<div align="right">
<select name="daysOfMonth" id="daysOfMonth" onchange="isValidDate()">
<option><?php if($day == 32){$day = 1; echo $day;}else{ echo $day;} ?></option> <!--problem-->
<option>....</option>
<?php
for($i = 1; $i <= $days_in_month; $i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
</div>
<label for="monthOfYear"></label>
<div align="center">
<select name="monthOfYear" id="monthOfYear" onchange="isValidDate()">
<option selected="selected"><?php echo $current_month; ?></option>
<option>........</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<label for="year"></label>
<select name="year" id="year" onchange="isValidDate()">
<option selected="selected"><?php echo $year; ?></option>
<option value="<?php echo $year + 1 ?>"><?php echo $year + 1 ?></option>
<option value="<?php echo $year + 2 ?>"><?php echo $year + 2 ?></option>
</select>
can anyone help?????????