There are few dates in the database. I must select another date using a jQuery datepicker. But the restriction is that, I must select a date(in the datepicker) which is only in the database and display this validated date in an 'alert'. The problem here is that in mysql, the date format is yyyy-mm-dd and in datepicker it is mm-dd-yyyy. How do I validate these two dates? I have searched a lot for a solution, but didn't find any.
The database date values and the datepicker selection are in the same file. associate.php
echo "<center><table border=2 cellpadding=25 cellspacing=0 width=200 style='border-collapse:collapse;table-layout:fixed;width:210pt'></center>
<tr>
<th> S.No</th>
<th>Date</th>
<th>Event</th>
</tr>";
while($record = mysql_fetch_array($myData)){
echo "<tr>";
echo "<td>" . $record['S.No'] . "</td>";
echo "<td>" . $record['Date'] . "</td>";
echo "<td>" . $record['Event'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<form id=\"dateform\" name=\"dateform\" action=\"#\" method=\"POST\"><br><br>
<table>
<tr><td>
<b>Select a date <b></td><td><input id=\"datepicker\" name=\"date\"size=\"15\"/></td></tr>
</table>
<br>
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</form>";
The following is the code to select the date from datepicker.
<script>
$(document).ready(function () {
$("#datepicker").datepicker();
$('form#dateform').submit(function(){
var aselectedDate = $('#datepicker').val();
if(aselectedDate !=''){
alert('You have selected ' + aselectedDate);
}
return false;
});
});
</script>