1

Are multiple onsubmit functions allowed in forms? Example:

<form name="form" method="POST" action="contactus.asp" onsubmit="return verify()" 
<!--*****CAN I ADD ANOTHER onsubmit FUNCTION HERE?***** -->>

2 Answers 2

4

Well, you can add any legal JavaScript statement including this:

<form onsubmit="return verify1() && verify2()">

or this

<form onsubmit="return verify1() || verify2()">

or more complex expressions which can include multiple function calls. Note that standard evaluation rules apply including short-circuit evaluation of logical expressions.

Sign up to request clarification or add additional context in comments.

Comments

0

I believe that wouldn't work. You should just make a wrapper function, and include the functions which you desire to execute, inside of that.

<script type="text/javascript">
    var run1 = function() { alert("first"); }
    var run2 = function() { alert("second"); }

    function sub() {
        run1();
        run2();
    }
</script>
<form name="form" method="POST" action="contactus.asp" onsubmit="javascript:sub();">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.