PirateBagel Posted May 10, 2007 Share Posted May 10, 2007 I have a large form, a few people keep hitting "enter" or something in a text box, thus sending the whole incomplete document. When they click on submit, i want a warning message to come up that says something along the lines of, "Are you sure you'd like to submit this?" with a yes/no option. I know this is a simple code, i've had it before. But I cannot remember what the actual code is, nor can I find it. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/ Share on other sites More sharing options...
cmgmyr Posted May 10, 2007 Share Posted May 10, 2007 add this to your button: onclick="return confirm('Are you sure?')" Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/#findComment-250153 Share on other sites More sharing options...
micah1701 Posted May 11, 2007 Share Posted May 11, 2007 the problem w/ onclick="return confirm('Are you sure?')" is that if they select "no" it will still send the form. this should really be in javascript, but anyway: onclick="var x = confirm('are your sure'); if(!x){ return false; }" or function rUsure(){ var confirmation = confirm("Are you Sure You want to submit this form"); if(confirmation == false){ return false; } } <form action="" method="" onsubmit="return rUsure()"> </a> Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/#findComment-250749 Share on other sites More sharing options...
cmgmyr Posted May 11, 2007 Share Posted May 11, 2007 always works for me? Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/#findComment-250757 Share on other sites More sharing options...
micah1701 Posted May 11, 2007 Share Posted May 11, 2007 always works for me? really? huh. maybe I was using a crappy browser the first time i tried using the confim() function. It was a few years ago and I've just always used my work around assuming that its the only way it works. Apparently it may not be necessary. Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/#findComment-250776 Share on other sites More sharing options...
ToonMariner Posted May 11, 2007 Share Posted May 11, 2007 you could always use the onsubmit="return confirm('Are you sure');" attribute of the form element. Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/#findComment-250887 Share on other sites More sharing options...
PirateBagel Posted May 14, 2007 Author Share Posted May 14, 2007 add this to your button: onclick="return confirm('Are you sure?')" Works like a charm, thank you. Link to comment https://forums.phpfreaks.com/topic/50862-solved-are-you-sure-after-clicking-submit/#findComment-253101 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.