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!

Non terminating?!?!?!?!? why but?

Status
Not open for further replies.

markmckillop

Programmer
Oct 19, 2002
3
DE
I am producing my first vbscript in a website, i only want it to produce a dialogue box if a field has not been filled in on form, i found very similar code to the one i have written, however mine doesnt work. When it detects no text entry, it shows the dialogue box and i ok it, it continues and executes the submit button and jumps pages. The code is below: and the result can be seen by clicking on It would seem as if the exit sub did not terminate the subroutine, as the final command in it is still being executed...!!!

<Script Language=&quot;vbscript&quot;>
Sub btSubmit_OnClick()
If Len(frmadd.Name.value) = 0 Then
MsgBox &quot;You must enter a name&quot;
frmadd.Name.focus
Exit Sub
End If
If Len(frmadd.Email.value) = 0 Then
MsgBox &quot;You must enter an e-mail&quot;
frmadd.Email.focus
Exit Sub
End If
If Len(frmadd.Message.value) = 0 Then
MsgBox &quot;You must enter a message to be posted&quot;
frmadd.Message.focus
Exit Sub
End If
frmadd.submit
End Sub
</Script>


Thanks
Mark
 
I took a copy of your page and put in Msgbox &quot;here I am&quot; just before the frmadd.submit and it did not display the message therefor it is exiting the sub routine. Regards
Steve Friday
 
Thanks steve, i should have thought of that...
Im still getting the same effect tho.. hows ur HTML? :)

Ive been at the site all day and by now im making stupid mistakes, a fresh set of eyes will probably spot a common error.
 
From what I can see and I am not that good at webby stuff,

I saved the source as steve.htm and ran it, it gave me the vbscript error as expected ie email not found, I then got a page not found error, when I saved the steve.htm as addition.asp and then ran steve.htm, it error'd but left me on the submit page.

Is the actual page called Addition.asp or is this another page??

Regards
Steve Friday
 
Umm well.. what im doing is producing a mini-discussion board, without all the hassle, what i want to do is use the post.htm to take the data in and when submit is clicked to run the asp page (after checking the fields) and then i want to load the asp page (additions.asp) which contains the code to add the data to the database which is on the server.

Im reading this from my head, with the help of some books. If im wrong, please correct me?

kindest regards
mark
 
needs a bit of tidying up but this time it left the focus where I wanted it and did not try to go to adition.asp

Function noname(field)
If Len(frmadd.Name.value) = 0 Then
MsgBox &quot;You must enter a name&quot;
field.focus
noname = False
Else
noname = True
End If
End Function

Function noemail(field)
If Len(frmadd.Email.value) = 0 Then
MsgBox &quot;You must enter an e-mail&quot;
frmadd.Email.focus
noemail = False
Else
noemail = True
End If
End Function

Function nomessage
If Len(frmadd.Message.value) = 0 Then
MsgBox &quot;You must enter a message to be posted&quot;
frmadd.Message.focus
nomessage = False
Else
nomessage = True
End If
End Function

Function frmadd_OnSubmit
msgbox test
Set Chkfield = frmadd.Name
If Not noname(Chkfield) Then
frmadd_OnSubmit = False
Exit Function
End If
Set Chkfield = frmadd.Email
If Not noemail(Chkfield) Then
frmadd_OnSubmit = False
Exit Function
End If
Set Chkfield = frmadd.Message
If Not nomessage(Chkfield) Then
frmadd_OnSubmit = False
Exit Function
End If

frmadd_OnSubmit = True
End Function Regards
Steve Friday
 
Sorry, couple of typo's in that. Here is the cleaned up version

Function noname(field)
If Len(frmadd.Name.value) = 0 Then
MsgBox &quot;You must enter a name&quot;
frmadd.Name.focus
noname = False
Else
noname = True
End If
End Function

Function noemail(field)
If Len(frmadd.Email.value) = 0 Then
MsgBox &quot;You must enter an e-mail&quot;
frmadd.Email.focus
noemail = False
Else
noemail = True
End If
End Function

Function nomessage(field)
If Len(frmadd.Message.value) = 0 Then
MsgBox &quot;You must enter a message to be posted&quot;
frmadd.Message.focus
nomessage = False
Else
nomessage = True
End If
End Function

Function frmadd_OnSubmit
Set Chkfield = frmadd.Name
If Not noname(Chkfield) Then
frmadd_OnSubmit = False
Exit Function
End If
Set Chkfield = frmadd.Email
If Not noemail(Chkfield) Then
frmadd_OnSubmit = False
Exit Function
End If
Set Chkfield = frmadd.Message
If Not nomessage(Chkfield) Then
frmadd_OnSubmit = False
Exit Function
End If

frmadd_OnSubmit = True
End Function
Regards
Steve Friday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top