markmckillop
Programmer
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="vbscript">
Sub btSubmit_OnClick()
If Len(frmadd.Name.value) = 0 Then
MsgBox "You must enter a name"
frmadd.Name.focus
Exit Sub
End If
If Len(frmadd.Email.value) = 0 Then
MsgBox "You must enter an e-mail"
frmadd.Email.focus
Exit Sub
End If
If Len(frmadd.Message.value) = 0 Then
MsgBox "You must enter a message to be posted"
frmadd.Message.focus
Exit Sub
End If
frmadd.submit
End Sub
</Script>
Thanks
Mark
<Script Language="vbscript">
Sub btSubmit_OnClick()
If Len(frmadd.Name.value) = 0 Then
MsgBox "You must enter a name"
frmadd.Name.focus
Exit Sub
End If
If Len(frmadd.Email.value) = 0 Then
MsgBox "You must enter an e-mail"
frmadd.Email.focus
Exit Sub
End If
If Len(frmadd.Message.value) = 0 Then
MsgBox "You must enter a message to be posted"
frmadd.Message.focus
Exit Sub
End If
frmadd.submit
End Sub
</Script>
Thanks
Mark