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?

1

4 Answers 4

1
if(!confirm("Are you sure you want to submit this?"))
{
    return false;//do not submit
}
//go ahead and submit
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

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.

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

Comments

Your Answer

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.