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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:55:39+00:00 2026-05-24T23:55:39+00:00

I have an event handler for a form submittal that needs to do some

  • 0

I have an event handler for a form submittal that needs to do some work. That work includes making an ajax call to perform some very specific validations. Because of the asynchronous nature, my intent was to preventDefault at the top of the event handler and, if everything went well, submit the form “manually” by triggering the submit() method.

Of course, that drops me into a loop. If I submit and all goes well, then the submit event handler is called when I resubmit. Is there any way to bypass the handler when I trigger the submit manually?

I should add that my geek karma is on empty today so I may be making this much harder than it has to be. If there’s a dead simple solution for what I’m trying to do, I’d love to hear it.

I should add that I’ve put a working solution in place by simply making the jQuery $.ajax call synchronous, but I can’t help feeling like there’s a more effective way of getting this done that I’m just not seeing today.

Thanks.

  • 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-24T23:55:40+00:00Added an answer on May 24, 2026 at 11:55 pm

    Don’t place a submit button on the form, place a button bound as a “validation” mechanism that (when correct) eventually submits.

    As far as backwards-compatibility, add a submit button, then use jQuery to replace the button with one of your custom-bound buttons (so in the event they don’t support javascript they can still proceed). Afterall, the server should have input validation(s) anyways for these situations/hacking of the form.

    Having re-thought it, move your validation logic’s trigger around. Bind to the click event of the submit button. This allows you to intervene just before the submit() is called. This event should also always return false, as you want to wait for the AJAX response to truly validate weather the form should submit or not.

    From there, await the AJAX response back, and call submit when all is well.

    In regards to backwards-compatibility, you should still have this validation logic server-side in the event that:

    1. there is no javascript support (maybe they’re using NoScript plugin?)
    2. The use feels like circumventing the form logic and starts hi-jacking the submission data.
    3. Any other (in)valid reason why the AJAX validation may not be done and catch and problems.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some event handler on a boundary class that manages a persistence mechanism
I have an event handler that needs to determine a type and execute code
I have an event handler for the TextBox.TextChanged event on a form of mine.
I have an event handler that will remove an element from a list of
In my Silverlight app I have an event handler that dynamically creates a new
I have the following: <select id=price_select></select> I have an event handler that invokes the
I have a simple event handler with a ItemAdding event that changes a column
I have a WPF form. It handles the KeyUp event and if the released
I have an event handler bound to the hover event using the .hover method,
I have a sharepoint event handler which I want to activate for a single

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.