Solved

Form with multiple onsubmit checks

Posted on 2008-10-15
6
518 Views
Last Modified: 2013-12-25
I have a couple functions in a form's OnSubmit event.
<form name="frm1" method="POST" action="show.asp" onsubmit="return CheckFrm1();return DoThisToo();">
But only one get's executed. Can I put multiple functions here?

Also is there an order of events (which get's ececuted first) Left to right?
0
Comment
Question by:StevenJames
  • 2
  • 2
  • 2
6 Comments
 
LVL 16

Expert Comment

by:sh0e
ID: 22727759
<form name="frm1" method="POST" action="show.asp" onsubmit="CheckFrm1();DoThisToo();">

return stops execution and gives a value to onsubmit.
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22727760
left to right
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 125 total points
ID: 22728510
StevenJames,

Can't you combine them or create a third that runs those functions and returns true/false to the submit?

If not then try ...

onsubmit="return (CheckFrm1() && DoThisToo());"

I haven't tried it like that so let me know if it doesn't work.  In a quick test it worked for me. :)

Let me know if you have any questions or need more information.

b0lsc0tt
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 4

Author Closing Comment

by:StevenJames
ID: 31506595
Thanks for the kick in the pants. lol
0
 
LVL 4

Author Comment

by:StevenJames
ID: 22731219
Thanks b0lsc0tt,

You gave me the idea of looking at other events, and since the user clicks on the submit button, I put the check in there, then my todostuff in the form's OnSubmit.

Works!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22734613
Great!  Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

821 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