streka
asked on
Cancel the Submit if vbscript function is true
I am validating dates with vbscript on submit How do I cancel the submit if the functon is true?
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="<%=SUBMITVALUE%>" LANGUAGE="VBScript" ONCLICK='If Not IsDate(BegFlightDate.value ) Or Not IsDate(EndFlightDate.value ) Then MsgBox("FlightDates must be in the date format")'>
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="<%=SUBMITVALUE%>" LANGUAGE="VBScript" ONCLICK='If Not IsDate(BegFlightDate.value
Sorry, left a few things out...
<html>
<head>
<title>Untitled</title>
<Script language="vbscript" >
Sub CheckDate_OnClick
dim beg1
beg1=(IsDate(Document.date 1.begdate1 .Value))
dim end1
end1=IsDate(Document.date1 .end1date1 .Value)
If beg1 Then
If end1 Then
Alert "Good Date"
Else
Alert "FlightDates must be in the date format"
End if
else
Alert "FlightDates must be in the date format"
End if
End Sub
</script>
</head>
<body>
<form name="date1">
<input type="text" name="begdate1" size="10">Begin Date <br>
<input type="text" name="end1date1" size="10">End Date <br>
<input type="button" name="CheckDate" value="Check Date">
</form>
</body>
</html>
<html>
<head>
<title>Untitled</title>
<Script language="vbscript" >
Sub CheckDate_OnClick
dim beg1
beg1=(IsDate(Document.date
dim end1
end1=IsDate(Document.date1
If beg1 Then
If end1 Then
Alert "Good Date"
Else
Alert "FlightDates must be in the date format"
End if
else
Alert "FlightDates must be in the date format"
End if
End Sub
</script>
</head>
<body>
<form name="date1">
<input type="text" name="begdate1" size="10">Begin Date <br>
<input type="text" name="end1date1" size="10">End Date <br>
<input type="button" name="CheckDate" value="Check Date">
</form>
</body>
</html>
ASKER
Yes, but how do I cancel the submit??? It would have to be a Submit button though.
No leave it as a regular button.
But where he has
Alert "Good Date"
instead put
date1.submit
I just added a similar comment to your other question.
But where he has
Alert "Good Date"
instead put
date1.submit
I just added a similar comment to your other question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yeah, that would work. Thanks.
Sub CheckDate_OnClick
dim beg=IsDate(BegFlightDate.v
dim end=IsDate(EndFlightDate.v
If beg Then
If end Then
Function Submit_Values
{ .....
}
else
Alert "FlightDates must be in the date format"
else
Alert "FlightDates must be in the date format"
...
<form>
<input type="button" name="CheckDate" value="Check Date">
</form>