I am trying to validate two dates to make sure they are really dates, then to make sure that the beginning date is less than the ending date, and lastly to make sure the beginning date is greater than the last date in the curent table. Here are some snippets of the code. The function works when I only have one if statement, but as soon as I add additional if's, it always returns a true.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% dim mdate %> ' set to the max date in the table later
<html>
<head>
<title>Update Availability</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function validation() {
if (ISDATE(document.EditMinister.date1.value)) 'never works
if (ISDATE(document.EditMinister.date2.value)) 'never works
if (document.EditMinister.date2.value < document.EditMinister.date1.value) ‘ this works well
{
alert ('The Ending Date must be LATER than the Beginning Date. Please Retry!');
return false;
}
else
if (document.EditMinister.date1.value < mdate ) 'never works
{
alert ('The Beginning Date must be greater than the last date in this schedule. Please Retry!');
return false;
}
else
return true;
}
//-->
</script>
‘other stuff goes here….
‘this determines the last date in the schedule and then sets the default to the first Saturday afterwards.
query = "SELECT MAX([MEVENT-DATE]) AS StartDay FROM [MSTR-EVENTS-MINISTERS] WHERE [MEVENT-EXTRAYN] = Yes"
set rs = con.execute(query)
mdate = rs("StartDay")
if Weekday(DATEVALUE(mdate)) <> 7 then 'Saturday
mdate = rs("StartDay") + 6
else
mdate = rs("StartDay") + 7
end if
‘other stuff goes here
‘this is the table
<table>
<form name=EditMinister method=post onSubmit="return validation();">
<table cellspacing = 10>
<tr><td align=right><font color='#0000FF'>Minister:</font><td><% =rs("indiv-name") %>
<tr><td align=right><font color='#0000FF'>E-Mail Address:</font><td><% =rs("indiv-email") %>
<tr><td align=right><font color='#0000FF'>First Date:</font>
<td><input type=text name=date1 size=12 maxlength="10" value=<% =DATEVALUE(mdate) %>>
<td align=right><font color='#0000FF'>Through:</font>
<td><input type=text name=date2 size=12 maxlength="10" value=<% =DATEVALUE(mdate) %>>
<tr><td><td>(mm/dd/yyyy)<td><td>(mm/dd/yyyy)
</table>
<table cellspacing = 10>
<tr><tr><tr><td><td><input type=submit value="Submit Dates"> <input type=reset><td><a href=availability.asp?iccode=<%=request("iccode")%>>View Unavailable Dates</a> </td><td><a ref="default.asp">Home</a>
</table>
</form>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% dim mdate %> ' set to the max date in the table later
<html>
<head>
<title>Update Availability</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function validation() {
if (ISDATE(document.EditMinister.date1.value)) 'never works
if (ISDATE(document.EditMinister.date2.value)) 'never works
if (document.EditMinister.date2.value < document.EditMinister.date1.value) ‘ this works well
{
alert ('The Ending Date must be LATER than the Beginning Date. Please Retry!');
return false;
}
else
if (document.EditMinister.date1.value < mdate ) 'never works
{
alert ('The Beginning Date must be greater than the last date in this schedule. Please Retry!');
return false;
}
else
return true;
}
//-->
</script>
‘other stuff goes here….
‘this determines the last date in the schedule and then sets the default to the first Saturday afterwards.
query = "SELECT MAX([MEVENT-DATE]) AS StartDay FROM [MSTR-EVENTS-MINISTERS] WHERE [MEVENT-EXTRAYN] = Yes"
set rs = con.execute(query)
mdate = rs("StartDay")
if Weekday(DATEVALUE(mdate)) <> 7 then 'Saturday
mdate = rs("StartDay") + 6
else
mdate = rs("StartDay") + 7
end if
‘other stuff goes here
‘this is the table
<table>
<form name=EditMinister method=post onSubmit="return validation();">
<table cellspacing = 10>
<tr><td align=right><font color='#0000FF'>Minister:</font><td><% =rs("indiv-name") %>
<tr><td align=right><font color='#0000FF'>E-Mail Address:</font><td><% =rs("indiv-email") %>
<tr><td align=right><font color='#0000FF'>First Date:</font>
<td><input type=text name=date1 size=12 maxlength="10" value=<% =DATEVALUE(mdate) %>>
<td align=right><font color='#0000FF'>Through:</font>
<td><input type=text name=date2 size=12 maxlength="10" value=<% =DATEVALUE(mdate) %>>
<tr><td><td>(mm/dd/yyyy)<td><td>(mm/dd/yyyy)
</table>
<table cellspacing = 10>
<tr><tr><tr><td><td><input type=submit value="Submit Dates"> <input type=reset><td><a href=availability.asp?iccode=<%=request("iccode")%>>View Unavailable Dates</a> </td><td><a ref="default.asp">Home</a>
</table>
</form>