Solved

How to handle VBScript of Form's OnSubmit?

Posted on 2000-02-18
4
1,724 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 50 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

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 information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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