When building forms using Web Forms for Marketers (WFFM), custom save actions can be added to save form data to a database or email a confirmation message. This post details an approach to disable the submit button to prevent multiple save actions from being triggered, such as sending multiple confirmation emails.
An important note about this code is that we do not disable the button if the form fails validation. On submit, ASP.NET’s
Page_ClientValidate is called to evaluate all validators defined within the group validator for the submit button
A Few Notes on Implementing
- Notice the naming convention for the submit control.
Sitecore.Form.Web.UI.Controls.SitecoreSimpleFormdefines the naming convention within the control’s
- When appending the script to the
onclickattribute of the submit button, do not use
OnClientClick()as the submit control will replace your code within
Wiring Up The Rendering
The last step in using our new code is to reference the class within the defined Form rendering. Updating the namespace, tag and assembly bring it all together: