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

Calling multiple functions from form onsubmit: VBscript Code not working

Posted on 2008-10-22
3
1,268 Views
Last Modified: 2013-11-26
I have few fields in my html form.  VBscript Code is written to validate data entry before submitting ASP file and then to the server.  The code that I have written is giving a message for empty field but erroneously submitting to the server.  Normally we expect to return back the form for corrections. My code is not doing so.  Did I make any mistake.

<html>
<head>
<SCRIPT LANGUAGE="vbscript">
Function MyForm_OnSubmit()
dim validation
validation=true
Call Check(Document.MyForm.Company.Value,     "Please enter a company name.")
Call Check(Document.MyForm.CName.Value,     "Please enter a name.")
Call Check(Document.MyForm.Location.Value,     "Please enter location of company.")
if validation = true then
MyForm_OnSubmit = true
else
MyForm_OnSubmit = false
end if
end function

Sub Check(ByVal FieldValue, ByVal message)
        If FieldValue = "" Then
            MsgBox message,8
            validation = False
            End If
        End Sub

</script>
</head>
<body>
<form name="MyForm" method=post action="abc.asp">
Enter name of the company
<input type="text" name="Company">
Enter your name
<input type="text" name="CName">
Enter location of company
<input type="text" name="Location">
<input type="Submit" value="submit changes">
</form>
</body>
</html>
0
Comment
Question by:smanthanims
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 50 total points
ID: 22775141
Looks like you are not calling the validation function on submit button click or on page submit.
0
 

Author Comment

by:smanthanims
ID: 22775698
Can the code be corrected to respond appropriately
0
 
LVL 13

Assisted Solution

by:TechTiger007
TechTiger007 earned 50 total points
ID: 22776382
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

808 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