Solved

Calling multiple functions from form onsubmit: VBscript Code not working

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

786 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