+ Start a Discussion
amitashtekaramitashtekar 

Not able to restrict user from clicking Command Button multiple times

hello,

 

i have created a visual force page. I am saving record on the button click.

but i am not able to restrict the user from clicking command button multiple times.

 

I have tried with providing action support on onclick and oncomplete event of the command button to change its disabled property.

Still the use is able click command button multiple times.

It creates unwanted records.

 

If any one has the solution, please share it with me.

Pradeep_NavatarPradeep_Navatar

You can use java script to hide the button after clicking first time by the user. Find below a sample code :

<apex:page Controller="your_controller">
<script>
function check()
{
   document.getElementById("{!$Component.frm.bt}").style.visibility='hidden';
}
</script>

<apex:form>
<apex:commandButton value="change" action="{!anyActionMethod}" id="bt" reRender="id of any region"/>
</apex:form>

</apex:page>