?
Solved

How to handle VBScript of Form's OnSubmit?

Posted on 2000-02-18
4
Medium Priority
?
1,743 Views
Last Modified: 2008-02-01
If a form's OnSubmit handler is a javascript function, it can return FALSE to prevent the form from being submitted.

But in my environment I have VBScript as my script language so when I created the onsubmit handler (via double clicking on the form's onsubmit entry in the script outline in Visual Interdev) it creates an onsubmit SUB instead of a function.

How then do I indicate an error had occured and that the form should not be submitted?
0
Comment
Question by:rascal
  • 2
4 Comments
 
LVL 1

Author Comment

by:rascal
ID: 2536359
Note: I have found that by setting the form's action="" in the onsubmit handler it appears to result in the effect I am after, but it seems to reload the current page and what would be most desirable would be for the current submit to simply cancel and no reload the current page.
0
 
LVL 1

Expert Comment

by:tbain44
ID: 2536617
i don't know what your code looks like, but if you run into an error, and you don't want the form to submit, try

window.event.returnValue = false;

or you can make your submit into <input type="button">

and then have an onClick event for the button which calls some sub or function and if whatever validation or whatever fails then don't do anything, and if you want the form to submit, then

frmName.submit() 'submits form

------------

by having action="" or by not specifing an action, all you do is have the form submit to itself instead of some specified page.

let me know if that doesn't work for you because i don't usually work with vbscript, except for my asp coding.
0
 
LVL 1

Author Comment

by:rascal
ID: 2536733
Thank you very much! That worked and was much cleaner than what I was using in that it did not navigate to itself in case of an error, it just canceled the onsubmit.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 200 total points
ID: 2537411
You can also change your handler into a function and return false-- the same way that it works under javascript.

<html>
<head>
<script language="vbscript">
function myForm_onsubmit()

  if document.myForm.message.value <> "hello there" then myForm_onsubmit = false

end function
</script>
</head>
<body>
<form name=myForm action="whatever.asp">
<input name="message">
<input type="submit">
</form>
</body>
</html>
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question