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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:24:32+00:00 2026-06-06T10:24:32+00:00

Currently my page has a submit button which is disabled when it is clicked,

  • 0

Currently my page has a submit button which is disabled when it is clicked, to prevent double submission.

<tr:commandButton onclick="this.disabled=true;" />

However, if there are errors in the form, the user will not be able to re-submit the form since the submit button is disabled.

Is there any way for me to disable the submit button only when it clears the form validation?

FYI my page looks something like this:

<rich:tabPanel headerAlignment="left" switchType="client" width="100%">
    <rich:tab label="#{cfsMsgs.main_tab_label}" name="mainTab">
        <rich:spacer height="20" />
        <ui:include src="add_main.xhtml" />
    </rich:tab>
    <rich:tab label="#{cfsMsgs.qualification_tab_label}" name="qualificationTab">
        <rich:spacer height="20" />
        <ui:include src="add_qualification.xhtml" />
    </rich:tab>

    <!-- ...and so on... -->

And on each tab there’s a mix of validation methods like

<tr:inputText ...>
    <tr:validateRegExp pattern="^\S.*" ... />
</tr:inputText>

…and

<tr:inputText validator="#{backingBean.validate}" ...>
</tr:inputText>

Is it possible to set my button to something like onclick=”this.disabled=[page error indicator, e.g. page.hasError or something similar]“?

EDIT 1:
An alternative is to re-render the button if the page fails to submit. I made a change to my code as follows:

<tr:commandButton onclick="this.disabled=true;" id="btnSubmit">
    <a4j:support event="oncomplete" reRender="btnSubmit" ajaxSingle="true" oncomplete="alert('done!');" />
</tr:commandButton>

The oncomplete event in a4j:support is for me to see if it was done. However when I tried running this, I didn’t see any alert. Does that mean I’m doing something wrong here?

  • 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-06T10:24:34+00:00Added an answer on June 6, 2026 at 10:24 am

    This works very fine for me (based on javaScript):

    //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 apply it in commandButton:

    <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

I am trying to prevent users from double clicking on the submit button for
Within an ASP.NET AJAX UpdatePanel on my page I have a submit button which
I am currently working on a page that has a date picker for one
The ASP.net page I am currently working on has a drop down list that
So, in my current project, when you navigate to the team page, which has
I currently have a page which is declared as follows: public partial class MyPage
The upload script in this page is currently uploading the images to the same
Is there a way to determine programmatically, using Python, which web page is currently
Is there a way to determine programmatically, using Python, which web page is currently
Currently I have a set of fields on a page. When the button is

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.