Solved

Calling multiple functions from form onsubmit: VBscript Code not working

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This video teaches users how to migrate an existing Wordpress website to a new domain.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

737 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