Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting Form Issue 3

Status
Not open for further replies.

TheConeHead

Programmer
Joined
Aug 14, 2002
Messages
2,106
Location
US
I have two submit buttons for a form - if one is clisked I want a validating function called before it is submitted and if the other is clicked I do not want the validator called - how could I do this?

Rugth now I am just calling the function via <form .... onsubmit="return check();">

[conehead]
 
keep the onsubmit as you have it...

but put a check in place for which submit button was pressed... if one was clicked, return true immediately, otherwise go through the validation process.



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Rugth now I am just calling the function via <form .... onsubmit="return check();">

remove the onSubmit action from here and try this

<input type=submit onClick="return check()" value="cnfirm">
<input type=submit value="No confirm">

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Just set up a javascript flag:
Code:
<script type="text/javascript">

var doValidate = true;

function check() {
   if (doValidate) {
      //submission stuff here
   }
}
</script>
<form onsubmit="return check()">
<input type="submit" value="submit with validation" onclick="doValidate = true" />
<input type="submit" value="submit without validation" onclick="doValidate = false" />
</form>

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Three different ways in less than 2 minutes!!!!

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Now for the exciting drama.... which one will he pick? [bomb]

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Code:
<script type="text/javascript">

var doValidate = true;

function check() {
   if (doValidate) {
      //submission stuff here
   }
}
</script>
<form onsubmit="return check()">
<input type="submit" value="submit with validation" onclick="doValidate = true" />
<input type="submit" value="submit without validation" onclick="doValidate = false" />
</form>

[conehead]
 
headbang.gif


-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Man, we really need a "bowing" icon...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
And a crown.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top