sjramsay
sjramsay

Reputation: 555

JQuery Disable Submit Call

I have asked this question: Using JQuery to Disable Submit button and/or get Value of form action

But possibly didn't explain myself correctly. I don't necessarily want to disable the submit button. What I want to do is, when this button is clicked I want to make a call and pass information to a pop up dialog. When the dialog appears it has a yes/no choice. When the user clicks yes/no it comes back and fires the original button command to continue to the next step of the checkout process.

But here is my problem, I have to use the class names to drill down to get to this button because there are other forms on this page that use the same button to continue on and so forth.

So I want to be able to start from the top div and work down the the continue button at the bottom. Then I want to make a call out to my modal dialog. The problem I have is I can't even get an alert box to pop up AND when I click the button it submits the information and goes on to the next step.

Sorry for the repeat to post to my original question, but I am not getting any play off of it. Thanks.

Upvotes: 0

Views: 65

Answers (1)

António Almeida
António Almeida

Reputation: 10087

You just need to add the onsubmit to your form, and then use a function with a confirm dialog, like this:

Demo at jsFiddle

HTML:

<form>
    Username: <input type="text" name="user" />
    <input type="submit" value="Submit"/>
</form>

JS:

$('form').submit(function(event) {
    return confirm("Are you sure you want to submit this form?");
});

Upvotes: 1

Related Questions