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 730631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:56:03+00:00 2026-05-14T06:56:03+00:00

I asked a question [ here ] recently and it’s just not providing me

  • 0

I asked a question [here] recently and it’s just not providing me with an answer. Here’s what I want to do and you can see my first attempt at the link above:

  1. User submits form
  2. Stop default submit action
  3. check to see if a similar entry exists in database
    1. If it does, display a notice asking them if they want to submit anyway and give an option to let them submit anyway (enable default action and submit it).
    2. If it does not, enable the default action on the form and let it submit

I’m at a loss. Any help is appreciated. Thanks gang.

EDIT for Simeon: Here is the code I’m using with your solution:

var forceSubmitForm = false;
$('#purchaser_contact').submit(function(){

  if(forceSubmitForm) return true;

  if( $("#id").val()=="" ){

    if( $("#fname").val()=='' || $("#city").val()=='' ){ alert('First Name and City are required fields. Please fill these in before continuing.'); return false; }

      $.ajax({
        type: "POST",
        url: 'ajax/contactSearch.php',
        data: ({ fname: $("#fname").val(), lname: $("#lname").val(), city: $("#city").val(), state: $("#state").val() }),
        success: function(d) {
            var obj = JSON.parse( d );
            if(obj.result != 0){
            $("#contactSearch").remove();
            $("#button-wrapper").before('<div id="contactSearch">'+obj.result+'</div>');
            $("#contactSearch").slideToggle('slow');                                
          } else {
            forceSubmitForm = true;
            $('#purchaser_contact').submit(); // Form will submit
          }
        }
      });   

      return false;

  } //END IF empty id

});     

This won’t work until the submit button is pushed a second time (ie, $('#purchaser_contact').submit(); is not submitting the form).

EDIT This never did work for me but Simeon’s answer is the closest and he claims it works in all major browsers so if it helps someone, great.

  • 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-05-14T06:56:04+00:00Added an answer on May 14, 2026 at 6:56 am

    This is the solution you are looking for.

    var forceSubmitForm = false;
    $('#myForm').submit(function(){
        if(forceSubmitForm) return true;
        $.ajax({
            // ...
            success: function(data){
                if(data.entry != 'OK'){ // or whatever check
                    forceSubmitForm = true;
                    $('#myForm').submit(); // Form will submit
                }else{
                    // Form will not be submitted
                }
            }
        });
        return false;
    });
    

    EDIT
    To prove to myself that this methodology works, I just created a sample page with a form and a submit button. This worked fine in all major browsers:

    $(function(){ // On DOM ready
        var forceSubmitForm = false;
    
        $('#purchaser_contact').live('submit', function() {
            if (forceSubmitForm){
                alert('submitting');
                return true;
            }
    
            // A callback function works in the same manner as a timeout
    
            setTimeout(function(){
                forceSubmitForm = true;
                $('#purchaser_contact').submit();
            }, 1500); // Submit after 1,5 seconds
    
            return false; // Do not submit immediately
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see here for a question I recently asked. The only answer you should
I recently asked a question here, and someone provided this answer: private void button1_Click(object
I recently asked/accepted an answer to a question I had earlier: How can I
I recently asked this question on here and got the answer. However I'm now
Here one more basic question asked in MS interview recently class A { public
I asked a precursor to this question here: Click link in DIV and show
I recently asked this question here and got some great answers! Custom SQL GROUP
I recently asked a question (and had it answered) here: jQuery Load JSON I
I was recently asked a weird question in an interview here it is; Private
OK, so this is leading on from another question I asked here recently. Basically,

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.