i have a bookin system with a drop down menu for day, month, and year...
i have validated them so as to alert the user when entering in past dates. however it still keeps the value of the past date instead of keepin the current date.
this is a section of my code:
<?php
$date = time();
$day = date('d', $date);
$month = date('m', $date);
$year = date('Y', $date);
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year);
$current_month = date('F');
echo $current_month;
?>
<script type="text/javascript">
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>
<div id="Content" style="height:450px">
<table width="100%" border="0" cellpadding="6" td style="margin-bottom:30px">
<tr>
<td align="center">Coastal View B+B<div id="returnPage"><a href="http://www.coastalview.site11.com/Index.html" target="_self">Return to Coastal View Home Page</a></div></td>
</tr>
<tr style="background-image:url(images/UIHeaderBreak.jpg); background-repeat:repeat-x">
<td style="height:40px"></td>
</tr>
<tr>
<td style="height:40px; font-size:12px"><p align="center">Select the dates you would like to stay and then click the check availability button.
This will show you which rooms/units are free for the dates you have selected.</p></td>
</tr>
</table>
<form action="AvailableRooms.php" method="post" name="CheckAvailability" target="_self" id="CheckAvailability">
<table width="50%" border="0" cellpadding="6" align="center">
<tr>
<td><label for="daysOfMonth"></label>
<div align="right">
<select name="daysOfMonth" id="daysOfMonth" onchange="isValidDate()">
<option><?php echo $day + 1; ?></option>
<option>....</option>
<?php
for($i = 1; $i <= $days_in_month; $i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
</div></td>
<td><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>
any ideas???