Solved

Calling multiple functions from form onsubmit: VBscript Code not working

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now