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

Despite an earlier question ( asked here ), our project is constrained to using
This question comes on the heels of the question asked here . The email
I asked this question before, Here however I think I presented the problem poorly,
I asked a question earlier which elicited some great responses. Here's the earlier question
This is in reference to the question previously asked The problem here is, each
Liu Chang asked a very similar question to this one here, Linux equivalent of
While looking at a micro-optimization question that I asked yesterday ( here ), I
Ok, i've read most relevant questions asked here previously on this but I still
Similar questions have been asked, but nothing exactly like mine, so here goes. We
This question builds off of a previously asked question: Pass by reference multidimensional array

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.