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

VBScript Client-Side Form Validation Problem 1

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
I have a basic client side VBSCript form validation script that just checks to make sure that two fields contain an entry before submitting the data to the server. The script works fine if there is data missing and will raise a message box to notify the user. However, if the data is OK then it gives the following error:

Object doesn''t support this property or method: 'pwform.submit'

pwform is the name of my form. The code of the script is as follows:

Sub Submit_onClick
if pwform.pwname.value = "" then
MsgBox "Please enter your name", , "Invalid Entry!"
Exit Sub
end if
if pwform.pwcomp.value = "" then
MsgBox "Please enter your company name", , "Invalid Entry!"
Exit Sub
end if
' Nothing has failed the test - submit the form
pwform.submit
End Sub

All help would be appreciated.
 
pwform.submit() doesn't work either.

I had tried that before - it just gives the same error.
I don't understand what the problem is. AS far as I am concerned, the code is fine.
 
Hi.

See the following. It works:

<Script Language=&quot;VBScript&quot;>
Sub sendMe
document.MyForm.method=&quot;POST&quot;
document.MyForm.action=&quot;myASP.asp&quot;
document.MyForm.submit()

End Sub

</Script>

regards, Kirilla
 
As Kirlla suggested, it is the document.form.submit part that matters with functions. The () are irrevelant. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Kirilla,

I have tried your suggestions and it is still not working. I don't have to reference the document when I am validating the contents so do I have to specify document when I am submitting. Maybe there is something wrong with the entire program. I have enclosed the ASP file. Please let me know if you see anything crazy in this:

<%
dim name : usr = request.form(&quot;pwname&quot;)
dim company : pass = request.form(&quot;pwcomp&quot;)

if len(name) > 0 then
%>

<!--Print out the input to make sure submit is working.-->
<HTML>
<BODY>
Your details are as follows:<br>
<%= name %> <%= company %>
</BODY>
</HTML>

<%
else
%>

<HTML>
<HEAD>
<TITLE>Insert Title Here</TITLE>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Submit_onClick
if MyForm.pwname.value = &quot;&quot; then
MsgBox &quot;Please enter your name&quot;, , &quot;Invalid Entry!&quot;
Exit Sub
end if

if MyForm.pwcomp.value = &quot;&quot; then
MsgBox &quot;Please enter your company name&quot;, , &quot;Invalid Entry!&quot;
Exit Sub
end if

' Nothing has failed the test - submit the form
MyForm.submit()
End Sub
-->
</SCRIPT>
</HEAD>
<BODY bgcolor=&quot;#eeeeee&quot;>

Please Enter the following Details.<br>
<FORM action=&quot;myASP.asp&quot; method=&quot;POST&quot; name=&quot;MyForm&quot;>
<TABLE>
<TR>
<TD ALIGN=&quot;LEFT&quot;>Name:</TD>
<TD ALIGN=&quot;LEFT&quot;><INPUT type=&quot;text&quot; id=pwname name=pwname></TD>
</TR>
<TR>
<TD ALIGN=&quot;LEFT&quot;>Company:</TD>
<TD ALIGN=&quot;LEFT&quot;><INPUT type=&quot;text&quot; id=pwcomp name=pwcomp></TD>
</TR>
<TR>
<TD ALIGN=&quot;RIGHT&quot; COLSPAN=2><INPUT type=&quot;button&quot; value=&quot;Submit&quot; name=&quot;Submit&quot;></TD>
</TR>
</TABLE>
</FORM>


</BODY>
</HTML>
<%
end if
%>
 
Me Again,

I changed from a Sub to the following function and it works fine.????? :)

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Function MyForm_onSubmit
Dim email

email = MyForm.pwemail.value

if MyForm.pwname.value = &quot;&quot; then
MsgBox &quot;Please enter your name&quot;, , &quot;Invalid Entry!&quot;
MyForm_OnSubmit = False
Exit Function
end if

if MyForm.pwcomp.value = &quot;&quot; then
MsgBox &quot;Please enter your company name&quot;, , &quot;Invalid Entry!&quot;
MyForm_OnSubmit = False
Exit Function
end if

' Nothing has failed the test - submit the form
MyForm_OnSubmit = True

End Function
-->
</SCRIPT>
 
You were using MyForm.submit, which is the same name as your submit button. You should name your submit button something other than &quot;submit&quot; if you are going to use the MyForm.submit() as an action call.

It was actually thinking you were trying to do something to the submit button itself, not the submit action of the form.

Hope that helps. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top