Tuesday, 7 January 2014

How to stop the user from clicking a page submit button more than once in apex


The standard way to push the page data back to the APEX server is to use an HTML button. One issue with HTML buttons is that they can be clicked more than once, and under certain circumstances this can cause issues. To ensure that the button can only be pressed once you can do the following.
alter button settings so that inside the URL redirect section the URL target value is set to
javascript:this.disabled=true;doSubmit(‘SUBMIT’)

Note that the value inside doSubmit(”) is the same as the button name.
You can even go one step further and replace the text of the button to something relevant like “Submitting….”. The following code does this
javascript:this.disabled=true;this.value=’Submitting….’;doSubmit(‘SUBMIT’);
The button now looks like this when it has been clicked

Thats it, the button is now coded so that the user can only click it once to submit the page. Any further clicks are ignored.

No comments:

Post a Comment