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)">