Link to home
Start Free TrialLog in
Avatar of rascal
rascalFlag for United States of America

asked on

How to handle VBScript of Form's OnSubmit?

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?
Avatar of rascal
rascal
Flag of United States of America image

ASKER

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.
Avatar of tbain44
tbain44

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.
Avatar of rascal

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of clockwatcher
clockwatcher

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial