jordanwb Posted January 15, 2008 Share Posted January 15, 2008 In my ASP form I have two submit buttons and I want to do validation. If button1 is pressed do this validation whereas if button2 two is pressed do this validation. I call the check in the form's onsubmit method. I saw this: http://forums.aspfree.com/html-javascript-and-css-help-7/detect-which-button-was-pressed-in-javascript-40818.html but it doesn't work. Link to comment https://forums.phpfreaks.com/topic/86174-solved-determining-which-submit-was-pressed/ Share on other sites More sharing options...
jordanwb Posted January 15, 2008 Author Share Posted January 15, 2008 I found out how. For others who are having the same problem: In the <head> tag: <script type="text/javascript" language="javascript"> <!-- var button_pressed; function check_form (the_form) { if (button_pressed == the_form.add_addr) { alert ("Foo!"); } else if (button_pressed == the_form.send_email) { alert ("It too is Foo!"); } return false; } --> </script> in my form: <input id="add_addr" onclick="button_pressed=this;" runat="server" type="submit" value="Add Address" /> <input id="send_email" onclick="button_pressed=this;" runat="server" type="submit" value="Mass Send" /> Note: If you're not using ASP take out the runat="server" Link to comment https://forums.phpfreaks.com/topic/86174-solved-determining-which-submit-was-pressed/#findComment-440125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.