When user clicks on the calendar image, date can be chosen. If the text field changes, the date will be compared with $today with Javascript. If the date is earlier than today, a mesage will be shown. I did these codes and the message could not be shown when I chose a date earlier than today.

function checkdate1()
{
var today = '<?php echo $today ; ?>';
if (document.form.startdate<today)
{
alert("Error!!!");
}
}


<?php $today = date("Y-m-d"); ?>
        <input name="startdate" id="startdate" type="text" value="<?php echo $today; ?>" onChange="checkdate1()"  required />     
 <img src="../images/calendar.jpg" onClick="displayCalendar(document.forms[0].startdate,'yyyy-mm-dd',this)">

You said that when user clicks on the calendar image, date can be chosen, why don’t you use only JavaScript and leave PHP on its server side? One good JS calendar that I am using in lot applications is JSCal2 that allows you set max and min date selection (but you can Google it for more),
http://www.dynarch.com/projects/calendar/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.