Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onsubmit return problem

Status
Not open for further replies.

ggrewe

IS-IT--Management
Jul 10, 2001
169
US
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;
else
return false;
}
//-->
</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">&nbsp;&nbsp;&nbsp;&nbsp;<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>
 
ggrewe,

Isdate() is not a valid built-in function for javascript. It's for vbscript.

As a practical matter, you might need to impose/request client to enter input at certain format you're comfortable with. "Free" format up to the client's caprice would be a nightmare for validation. A simple textbox input would be nearly so if not enough notification to client.

Some standard q&a including client-side validations can be found here:

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top