Solved

Form with multiple onsubmit checks

Posted on 2008-10-15
6
523 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arrays and radio buttons 10 35
Html date format 9 20
null, truthy, falsey confusion 25 28
Read text on Table 7 25
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
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.

679 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