scripter73
Programmer
Hi,
I have a date range form that's pre-populated (ok, hard-coded for now) with today's date.
I want to restrict the user to only using one date. I don't care what date they enter in the 1st MM/DD/YYYY section, but the 2nd MM/DD/YYYY date must be the same as the first.
Preferably, when the user clicks the Submit I'd like the following:
* Compare the first set of dates to the second set. If
they're not the same, fill in the last set of dates with values from the first (this is an extra perk).
* Alert the user and not submit the page.
I created a form and some JS and found a few examples of this forum, but I'm receiving a JS error on my onclick attribute. It doesn't like that line and says an object was expected.
Any help/insight you can provide is greatly appreciated.
My current code follows:
<html>
<head>
<title>
<script language="Javascript">
<!---
function checkDate(smonth,sday,syear,emonth,eday,eyear)
{
var date=smonth+sday+syear;
var old=emonth+eday+eyear;
var f = new Date(date);
var n = new Date(old);
if (f != n)
{ return true }
else
{ alert("You cannot enter more than one day's date for this particular view."
return false;
}
}
//--->
</script>
</title>
</head>
<body>
<table cellpadding=0 cellspacing=0 width=100% colspan=2 border=0>
<tr>
<td><b><p>Please enter a date range and click on the report you would like to view.</b></p></td>
</tr>
</table>
<form name="vaform" action="form2.cfm" method="post">
<TABLE width=60% cellpadding=0 cellspacing=0 border=0>
<TR>
<TD><input type="text" name="startmonth" value="02" maxlength=2 size=3>/</TD>
<TD><input type="text" name="startday" value="27" maxlength=2 size=3>/</TD>
<TD><input type="text" name="startyear" value="2001" maxlength=4 size=5></TD>
<TD>TO </TD>
<TD><input type="text" name="endmonth" value="02" maxlength=2 size=3>/</TD>
<TD><input type="text" name="endday" value="27" maxlength=2 size=3>/</TD>
<TD><input type="text" name="endyear" value="2001" maxlength=4 size=5></TD>
<TD> </TD>
<input type="hidden" name="sdate" value="document.vaform.startmonth.value/document.vaform.startday.value/document.vaform.startyear.value">
<input type="hidden" name="edate" value="document.vaform.endmonth.value/document.vaform.endday.value/document.vaform.endyear.value">
<TD><input type="submit" name="Submit" value="Submit" onClick="return checkDate('document.vaform.startmonth.value','document.vaform.startday.value','document.vaform.startyear.value','document.vaform.endmonth.value','document.vaform.endday.value','document.vaform.endyear.value')"></TD>
<TD><a href="./homepage.cfm">Return to Homepage</a></TD>
</TR>
<TR>
<TD><font size=-3>MM</font></TD>
<TD><font size=-3>DD</font></TD>
<TD><font size=-3>YYYY</font></TD>
<TD> </TD>
<TD><font size=-3>MM</font></TD>
<TD><font size=-3>DD</font></TD>
<TD><font size=-3>YYYY</font></TD>
<TD> </TD>
</TR>
</TABLE>
</form>
</body>
</html>
Thanks,
scripter73
Change Your Thinking, Change Your Life.
I have a date range form that's pre-populated (ok, hard-coded for now) with today's date.
I want to restrict the user to only using one date. I don't care what date they enter in the 1st MM/DD/YYYY section, but the 2nd MM/DD/YYYY date must be the same as the first.
Preferably, when the user clicks the Submit I'd like the following:
* Compare the first set of dates to the second set. If
they're not the same, fill in the last set of dates with values from the first (this is an extra perk).
* Alert the user and not submit the page.
I created a form and some JS and found a few examples of this forum, but I'm receiving a JS error on my onclick attribute. It doesn't like that line and says an object was expected.
Any help/insight you can provide is greatly appreciated.
My current code follows:
<html>
<head>
<title>
<script language="Javascript">
<!---
function checkDate(smonth,sday,syear,emonth,eday,eyear)
{
var date=smonth+sday+syear;
var old=emonth+eday+eyear;
var f = new Date(date);
var n = new Date(old);
if (f != n)
{ return true }
else
{ alert("You cannot enter more than one day's date for this particular view."
return false;
}
}
//--->
</script>
</title>
</head>
<body>
<table cellpadding=0 cellspacing=0 width=100% colspan=2 border=0>
<tr>
<td><b><p>Please enter a date range and click on the report you would like to view.</b></p></td>
</tr>
</table>
<form name="vaform" action="form2.cfm" method="post">
<TABLE width=60% cellpadding=0 cellspacing=0 border=0>
<TR>
<TD><input type="text" name="startmonth" value="02" maxlength=2 size=3>/</TD>
<TD><input type="text" name="startday" value="27" maxlength=2 size=3>/</TD>
<TD><input type="text" name="startyear" value="2001" maxlength=4 size=5></TD>
<TD>TO </TD>
<TD><input type="text" name="endmonth" value="02" maxlength=2 size=3>/</TD>
<TD><input type="text" name="endday" value="27" maxlength=2 size=3>/</TD>
<TD><input type="text" name="endyear" value="2001" maxlength=4 size=5></TD>
<TD> </TD>
<input type="hidden" name="sdate" value="document.vaform.startmonth.value/document.vaform.startday.value/document.vaform.startyear.value">
<input type="hidden" name="edate" value="document.vaform.endmonth.value/document.vaform.endday.value/document.vaform.endyear.value">
<TD><input type="submit" name="Submit" value="Submit" onClick="return checkDate('document.vaform.startmonth.value','document.vaform.startday.value','document.vaform.startyear.value','document.vaform.endmonth.value','document.vaform.endday.value','document.vaform.endyear.value')"></TD>
<TD><a href="./homepage.cfm">Return to Homepage</a></TD>
</TR>
<TR>
<TD><font size=-3>MM</font></TD>
<TD><font size=-3>DD</font></TD>
<TD><font size=-3>YYYY</font></TD>
<TD> </TD>
<TD><font size=-3>MM</font></TD>
<TD><font size=-3>DD</font></TD>
<TD><font size=-3>YYYY</font></TD>
<TD> </TD>
</TR>
</TABLE>
</form>
</body>
</html>
Thanks,
scripter73
Change Your Thinking, Change Your Life.