0

I have a simple form built. A drop-down menu, a text field, and a submit button.

When the submit button is pressed, it posts the item selected in the dropdown and the text inputed in the text field.

I want to add a confirmation pop using JavaScript/jQuery. When they press "submit" a pop-up will appear that says "Are you sure you want to submit this?"

If the user says "OK", it continues with the POST action, and calls the PHP action script.

Is this possible, if so, how?

Till Helge
9,3212 gold badges43 silver badges56 bronze badges
asked Jan 14, 2013 at 21:25
1

4 Answers 4

1
if(!confirm("Are you sure you want to submit this?"))
{
 return false;//do not submit
}
//go ahead and submit
answered Jan 14, 2013 at 21:27
Sign up to request clarification or add additional context in comments.

Comments

0

Yes it is. You can define a onSubmit handler and if it return false, the submit is aborted.

http://www.javascripter.net/faq/confirm.htm

answered Jan 14, 2013 at 21:27

Comments

0

There's a good example over at Tizag. This can be adapted for any confirmation. This can also be done with jQuery if you want to, but it's just as easy with the native javascript functions.

answered Jan 14, 2013 at 21:28

Comments

0

Developped @justin answer

// in domReady 
$('#formID').submit(confirmSubmit);
function confirmSubmit(e){
 if(!confirm("Are you sure you want to submit this?")){
 return false;//do not submit
 }
 //go ahead and submit
}

take a look at the jQuery submit event documentation

answered Jan 14, 2013 at 22:35

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.