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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object required error when referencing form

Status
Not open for further replies.

jjoy123123

Programmer
Oct 22, 2002
20
0
0
US
I'm getting a run-time error "Object Required 'DetailForm'" on the following Validate function when it executes the IsDate line. Why won't it recognize the DetailForm as the form name? FYI - I'm using VB Script because I'm working on the intranet where everyone uses IE. Any information would be GREATLY appreciated!


VALIDATE FUNCTION -------------------------------------------------------------------------
<script language=&quot;VBScript&quot;>
Function Validate()
If IsDate(DetailForm.CallDate.Value) = False Then
MsgBox &quot;Please enter a valid call date.&quot;
Validate=false
Else
Validate=true
End IF
End Function
</script>



FORM FIELD INFORMATION ------------------------------------------------------------
<Form name=&quot;DetailForm&quot; ACTION=&quot;Save_Call.asp&quot; METHOD=&quot;POST&quot; onsubmit=&quot;Validate()&quot;>
<input type=&quot;text&quot; name=&quot;CallDate&quot; Value=&quot;12/12/2003&quot;>



 
Actually, I copied your code into a webpage and it ran just fine. I modified your function just so that I could see that it was working properly. Here is the full text of the code that I am working with:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;VBScript&quot;>
Function Validate()
If IsDate(DetailForm.CallDate.Value) = False Then
MsgBox &quot;Please enter a valid call date.&quot;
Validate=false
Else
MsgBox &quot;Date is valid.&quot;
Validate=true
End IF
End Function
</script>

</head>

<body>
<Form name=&quot;DetailForm&quot; ACTION=&quot;Save_Call.asp&quot; METHOD=&quot;POST&quot; onsubmit=&quot;Validate()&quot;>
<input type=&quot;text&quot; name=&quot;CallDate&quot; Value=&quot;12/12/2003&quot;/>
<input type=&quot;submit&quot;/>
</form>
</body>
</html>


Try copying that and see if it works. If it doesn't, try rewriting your function so that it accepts an argument and when you call the function in the onsubmit event, pass the name of the form to it. Let me know how it works out.


Hope that helps.
 
I finally got it to work!

It only worked once I set the form ID=&quot;DetailForm&quot;. Apparently it would not recognize DetailForm unless its ID was set. Any ideas on why this would happen?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top