Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

How to add client side logic after a form has been submitted and validated?

« Go Back

Information

 
Article Number000094378
EnvironmentProduct: Sitefinity
Version: 10.x, 11.x
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description
How to add client-side logic after a form has been submitted and validated?
How to execute javascript after a form has been successfully validated?
Steps to Reproduce
Clarifying Information
This applies only for the WebForms Forms widget.
Error Message
Defect/Enhancement Number
Cause
Resolution
1. Turn on the Ajax submit option of the widget. Todo so go to the widget's Advanced settings and look for the "UseAjaxSubmit" then set it to 'true'.
2. Drop a Javascript widget on the same page where the Forms widget is and add the following to it:
 
Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.prototype.processFormSubmitAction = function() {

var submitAction = this._getSubmitAction();

var pageUrl = this._getSubmitPageUrl();

var successMessage = this._getSubmitSuccessMessage();

switch (submitAction) {
    case 'PageRedirect': {
        if (pageUrl != null) {

              //add logic here in case the widget is configured to redirect to another page

             window.location.replace(pageUrl);
        }
    } break;
    case 'TextMessage': {
         if (successMessage != null) {

             //add logic here in case the widget is configured to show success message

             $('#' + this.get_formControlsContainerId()).hide();
             $('#' + this.get_successMessageBlockId()).text(successMessage);
             $('#' + this.get_successMessageBlockId()).show();
         }
     } break;
     default: {
          throw new Error('Not implemented form submit action - ' + submitAction);
          }
      }
  }

 
Workaround
Notes
Attachment 
Last Modified Date2/12/2019 9:22 AM