Search In This Blog

2016-08-12

Prevent double submission of forms.

When save customize form data with apex:commandButton, double submission is needed to be attention.

If you use standard control and standard save function, salesforce may help you to prevent double submission. But when you use a customize button action to save data, you will need to do by yourself.

Double submission can be prevented by JavaScript easily and efficiently.

Put code below inside <head></head>
<script type="text/javascript"> 
var isSave = false; 
function check(){ 
if (!isSave) { 
isSave = true; 
return true; 
} 
return false; 
} 
</script> 

Then put <apex:commandbutton> inside of <apex:form></apex:form>.
<apex:commandButton action="{!test}" value="Refresh" onclick="return check();"/>
*value is the button's name; when click this button, function check() will be called and return boolean value.

No comments:

Post a Comment