Skip navigation
Currently Being Moderated

How to prevent duplicate submission?

May 31, 2012 3:34 AM

Tags: #duplicate #submission

Hello!

 

I have a page for gathering some data:

 

private function saveHander():void {

    // Gathering data into database.

}

 

<mx:TextInput id="name" />

<mx:TextInput id="age" />

<s:Button id="Submit" label="Submit" click="saveHandler();" />

 

When focus on submit button,I click at the button and press the space bar at the same time,saveHander function execute two times.

How can I prevent duplicate submission? thanks!

 
Replies
  • Currently Being Moderated
    May 31, 2012 4:43 AM   in reply to NoMan\'sLand

    Hi

     

    you could put boolean in place to cancel second submit and unlock it again once request is returned

     

    private var pass:boolean = true;

    private function saveHander():void {

        // Gathering data into database.

              if(pass == true)

              {

                   pass = false;

                   //send request here

              }

    }

    // fire this when data requested returns

    private function sendRequestReturn():void

    {

         pass = true;

    }

     

    <mx:TextInput id="name" />

    <mx:TextInput id="age" />

    <s:Button id="Submit" label="Submit" click="saveHandler();" />

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 8:54 AM   in reply to NoMan\'sLand

    Assuming this is a form you are attempting to save, good UX practice is to disable the form once you begin local form validation (submit button clicked) prior to forming your data packet for save.

    Doing so will prevent the anomaly you are experiencing.

     

    In other cases where the above practice is not practical, you can setFocus to another component (off the submit button) because as long as the focus remains on the button, depressing the space bar will trigger the mouse event for the button. Research ADA compliance if you want more details.

     

    HTH. 

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points