[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to handle VBScript of Form's OnSubmit?

Posted on 2000-02-18
4
Medium Priority
?
1,738 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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…
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/…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 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