Solved

Calling multiple functions from form onsubmit: VBscript Code not working

Posted on 2008-10-22
3
1,272 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
[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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

735 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