Confirm Form Submission

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Confirm Form Submission

Post by jamiel »

Hi All,

Having some problems getting Javascript to use the Action I specified for my form in my HTML when using the following function.

Code: Select all

function confirm_submit(form, msg)
{
        response = confirm(msg);
        if (response == false) {
                return false;
        } else {
                form.submit();
                return true;
        }
}
If I use onSubmit="return confirm_submit(this, 'my message')" , if I choose No it does as expected, but if I select Yes, it submit's the form but ignore's the action I have specified in my form.

Any ideas?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

hmm... why not use simple onsubmit='return confirm("message here");' ?
Post Reply