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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:40:05+00:00 2026-05-25T10:40:05+00:00

I have a problem when I submit the form (pressing ENTER key or clicking

  • 0

I have a problem when I submit the form (pressing ENTER key or clicking mouse) – if I press it x times quickly, faster then actual view is recreated (e.g. ten times in one second), the form data are sent ten times and ten times are saved to database.

And no matter if there is some validation, e.g. check that data can be saved only once.

Next submit, after view refresh, works normally. Data are not saved, because the validator is working now..

So, malevolent user fill the form and instead of submit it normally, he is quickly clicking on submit button until the view is rebuilded and I have X records in database instead of one 🙂

How can I prevent this strange behaviour?

How to forbid to press submit button until view is rebuild?

  • 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-25T10:40:05+00:00Added an answer on May 25, 2026 at 10:40 am

    SOLUTION:

    //Initialize our submit flag to false
    var formSubmitted = false;
    
    /**
     * Prevent from submitting a form more than once
     * @returns {Boolean}
     */
    function submitForm()
    {   
      //has the form been submitted before?
      if( formSubmitted == true )
      {
         alert("This form has already been submitted!");
         return false;
      }
      formSubmitted = true;
    
      return true; // Submit form
    }
    

    and the submit button:

    <h:commandButton ... action="#{bean.action}" onclick="return submitForm();"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so here's the problem I have one form, it outputs search results after submit,
I have a problem with my form when I try to submit with ajax.
Guys i have a little problem when i submit my form the page gets
I have problem to update user data in cakephp. When I submit form I
I am using the jQuery disable on submit plug-in but I have a problem.
i have problem with jquery submit and post. I would like to submit a
I have a form that I need to submit automatically... (the fields are already
I want to have a confirmation from the user before they submit a form.
I have a problem on submitting an asp.net mvc form that is using Xval
I'm trying to learn how to validate a form and I have this problem:

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.