0

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

Edited by Dani: Formatting fixed

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by jkon
0

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/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.