I am facing a problem while disabling the command button after one click. I am using action function for this but its not working well don't know why?? can any body please help me to correct my code if i am wrong?
<script>
function validationRule(){
savePost();
}
</script>
vf code:
<apex:actionStatus startText="Loading..." stopText="" id="str"> </apex:actionStatus>
<apex:actionRegion >
<apex:actionFunction name="savePost" action="{!save}" rerender="" status="str" >
</apex:actionFunction>
</apex:actionRegion>
<apex:commandButton image="{!URLFOR($Resource.Test, 'Post_Button.png')}" value="Post" onclick="validationRule();" />
Please correct me..
It looks like you're not setting the disabled attribute on the Command Button. Use this.disabled=true;
or this.disabled="disabled";
.
Try this:
<apex:page standardcontroller="Account">
<apex:form >
<script type="text/javascript">
function validate() {
// validate code here
savePost();
}
</script>
<apex:actionfunction name="savePost" action="{!save}" rerender="" status="str" />
<apex:commandbutton value="Save New Account Value" onclick="this.disabled='disabled'; validate();" />
<apex:actionstatus startText="Loading..." stopText="" id="str" />
</apex:form>
</apex:page>