Hello All
i enter date using datepicker. when i enter date and enter other values in the form after i press submit it should check whether date entered is either should be current date or it should be greater than current date. please tell me how to do it using javascript. if the date entered is less than current date it should stop me to proceed to next page. please help me how to write
<script>
this is my script
function validate()
{
var v=document.addevents;
HoldDate=new Date();
HoldDate1= ((HoldDate.getMonth()+1) + "/" + HoldDate.getDate() + "/" + HoldDate.getYear());
/*if(sdate < odate)
{
alert("Submissionn Date should not be less than opening date");
return false;
}*/
var isError = false;
var errorMessage = "";
if(v.eventtitle.value=="")
{
alert("Please Enter Event Title");
v.eventtitle.focus();
return false;
}
if(v.eventdate.value=="")
{
alert("Please Enter Event Date");
v.eventdate.focus();
return false;
}
if(v.eventdate.value !=HoldDate1)
{
alert("Submissionn Date should not be less than current date");
return false;
}
else
{
alert(v.eventdate.value);
return false;
}
/*if(v.eventdate.value !=HoldDate1)
{
}*/
if(v.hours.selectedIndex == 0 )
{
alert("Please Enter Hours");
v.hours.focus();
return false;
}
if(v.mins.selectedIndex == 0 )
{
alert("Please Enter Mins");
v.mins.focus();
return false;
}
if(v.time.selectedIndex == 0 )
{
alert("Please Enter time");
v.time.focus();
return false;
}
if(v.location.value=="")
{
alert("Please Enter Event location");
v.location.focus();
return false;
}
if(v.comments.value=="")
{
alert("Please Enter Event Description");
v.comments.focus();
return false;
}
if(v.location.value=="")
{
alert("Please Enter Event Location");
v.location.focus();
return false;
}
}
</script>
this is my form
<form name="addevents" action="eventsadd.php" method="post">
<table width="100%">
<tr>
<td align="center"><table width="70%" height="160" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="24%" height="25" align="left" class="linkstext" scope="col"><span class="style1">Event Title </span></th>
<th width="3%" align="left" scope="col">:</th>
<th width="73%" align="left" scope="col"> <input type="text" name="eventtitle" size="20"/> </th>
</tr>
<tr>
<th width="24%" height="25" align="left" class="linkstext" scope="col"><span class="style1">Event Date</span></th>
<th width="3%" align="left" scope="col">:</th>
<th align="left" scope="col"><table width="164" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="120"><input type="text" name="eventdate" size="20" readonly/></td>
<td width="44" align="center"> <img src="images/calendar.gif" onClick="popUpCalendar(this, document.all.eventdate,'mm/dd/yyyy');"></td>
</tr>
</table></th>
</tr>
<tr>
<th height="25" align="left" class="linkstext" scope="col"><span class="style1">Event Time </span></th>
<th align="left" scope="col">:</th>
<th align="left" scope="col"><!--<input type="text" name="eventtime" value="<?php #echo $ptime; ?>" size="20"/>-->
<?php echo "<select name=hours>";
echo " <option>select </option>";
for($i=1;$i<13;$i++)
{
echo "<option value=$i>$i</option>";}
echo "</select>";
echo "<select name=mins>";
for($i=0;$i<60;$i++)
{
echo "<option value=$i>$i</option>";}
echo "</select>";
echo "<select name=time>
<option>select </option>
<option value=AM>AM</option>
<option value=PM>PM</option>
</select>";
echo"</td></tr><tr><td height=7></td></tr>";
?>
</th>
</tr>
<tr>
<th height="25" align="left" class="style1" scope="col">Event Location</th>
<th align="left" scope="col">:</th>
<th align="left" scope="col"><label>
<input name="location" type="text" id="location">
</label></th>
</tr>
<tr>
<th height="25" align="left" class="linkstext" scope="col"><span class="style1">Event Description </span></th>
<th align="left" scope="col">:</th>
<th align="left" scope="col"> <textarea name="comments" cols=40 rows=6></textarea> </th>
</tr>
<tr>
<th height="35" colspan="3" align="center" scope="col">
<input name="Submit" id="submitbutton" type="Submit" class="tablesearchbox" value="Submit" onClick=" return validate(this.form);" />
eventdate is the field name
please help me how to solve my error
thanks in advance