Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8996617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:46:42+00:00 2026-06-15T23:46:42+00:00

I am using some javascript to check a form field against an array of

  • 0

I am using some javascript to check a form field against an array of possible matches. Dependent on match user is them presented with a confirm window and dependent on result form is either submitted or user is returned to the page. This process works as expected in Firefox and Chrome but in IE and Opera an alternative submit is still being triggered. Can anyone suggest how I can fix this?

Script is trimmed of most data for simplicity.

$(function(){
    var check = ["All", "array", "values"];
    $('#Next').click(function(){
        $(this).addClass('hit');
        $('#Cancel').attr('disabled', 'disabled');
    });
    $('#Form').bind('submit', function(){
        if($(this).find('.hit').attr('id')=='Next'){
            $('#Next').removeClass('hit');
            var match = $('input[name="WHAT"]', $('#idBothAddressesTable')).val().trim();
            if(match.length==0){
                var postCode = $('input[name="WHAT2"]', $('#idBothAddressesTable')).val().trim();
            }
            var matched = $.inArray(match, check);
            if(matched != -1){
                var ask = confirm("This is the case, proceed or cancel");
                if(ask==true){
                        $.post('dowhat.php',{flag: 1}, function()){
                        $('#Form').unbind('submit').submit();
                    });
                }
                else{
                    ('#Cancel').removeAttr('disabled');
                    return false;
                }
            }
        }
    });
});

Form actually has two submit values. Other than that is pretty basic, have trimmed away the bulk for simplicity again.

<form action="nextpage.php" method="post" id="Form">
    <input type="text" name="WHAT" />
    <input type="text" name="WHAT2" />
    <input type="submit" name="CANCEL" value="Cancel" id="Cancel" />
    <input type="submit" name="NEXT" value="Next" id="Next" />
</form>

In firefox and chrome this appears to work when someone meets meets the ask==true critera. The $.post goes ahead and the form is submitted as if the “NEXT” submit were clicked.

However in IE and Opera the $.post occurs but the form is submitted as if the the “CANCEL” were clicked.

Can anyone explain this to me, I can’t seem to find a solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:46:43+00:00Added an answer on June 15, 2026 at 11:46 pm

    You have a form with two submit buttons and you are telling the form to be submitted.

    The result is undefined: each browser handle it in its own way! So, instead of telling form to submit, I suggest you to call the click event of the submit button you need to call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using some Javascript to create a text field once an certain
I am trying to do some simple form validation using javascript object values. I
I'm using some javascript/jquery in an asp.net mvc view and I'm appending some html
I am currently using some javascript to scroll some text on my web page.
I have some javascript that I am using for some audio on my website:
I am using some pre-written JavaScript from polldaddy. They have a JavaScript option which,
I'm working on games using javascript some html and css, and I was wondering
I've been using Firebug to debug some javascript I have on one of my
I'm using sed for windows to do search and replace on some javascript files,
I’ve two div boxes that I’m using as a expand-collapse with some javascript but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.