We help IT Professionals succeed at work.
Get Started

Multiple Submit buttons

-Matthew-
-Matthew- asked
on
237 Views
Last Modified: 2012-08-14
Is it possible to have two submit buttons, one that runs javascript and one that submits without running the script or just by passes the validation.

I know I could just put an image there and send them on, but if I can just say submit and move on using the same form. I guess this is more of curiosity question.

Thanks
<script type="text/javascript" language="javascript">
	function validateForm()
{
var x=document.forms["myForm"]["guardian_household"].value
var y=document.forms["myForm"]["guardian_tanf"].value
if (x==null || x=="" || y==null || y=="")
  {
  alert("All fields required.");
  return false;
  } 
  
}
</script>

<form name="myForm" action="" onsubmit="return validateForm()" method="post">
Name: <input type="text" name="guardian_household" id="guardian_household" /><br />
Tanf: <input type="text" name="guardian_tanf" id="guardian_tanf" />

<input name="answers" type="submit" class="submitbutton" id="answers" value="Submit Case Number and continue" />

<input name="answers" type="submit" class="submitbutton" id="answers" value="I Do Not Have A TANF / Food Stamp Case " />

</form>

Open in new window

Comment
Watch Question
Web Ninja at large
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE