I'm having a problem getting the message using the Ajax jquery. I'm trying to validate the Date. The date should not accept previous dates and accept the dates after 7 days of the current date.
The Main Page is reservation.php
When the condition is not met it should echo a javascript alert in the reservation.php
echo ("<script language='Javascript'> alert('Preferred Date Is Not Allowed!')</script>");
If the condition is met it should echo a message
echo "<img src='img/information.png' style='width:30px;height:30px;'/><i style='color:yellow;'>No. of passengers on " . $format . ": " . $totalpass . ' </i><br>';
This is my Code: Reservation.php
<script type="text/javascript">
$(document).ready(function() {
$("#date").change(function() {
$.get('getdate.php?parent_cat=' + $(this).val(), function(data) {
$("#sub_cat2").html(data);
});
});
});
</script>
<input class="form-control datepicker" name="r_date" id="date" type="text" placeholder="reservation date">
<div id="subcat2"> </div>
getdate.php
$parent_cat = $_GET['parent_cat'];
if(strtotime($format) <= strtotime(date("Y-m-d",strtotime('+7 days')) ))
{
echo ("<script language='Javascript'> alert('Preferred Date Is Not Allowed!')</script>");
}
else
{
echo "<img src='img/information.png' style='width:30px;height:30px;'/><i style='color:yellow;'>No. of passengers on " . $format . ": " . $totalpass . ' </i><br>';
}
Kindly help me please Thank you!