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
Solved

How to handle VBScript of Form's OnSubmit?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pass through dll 2 91
Problems using Provider=OraOLEDB.Oracle via VBScript/Classic ASP 5 89
ASP server side get value 15 35
alert(innerHTML); 8 32
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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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