+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Inbuilt form with custom forms widget + widget designer

Inbuilt form with custom forms widget + widget designer

2 posts, 0 answered
  1. Quba
    Quba avatar
    15 posts
    Registered:
    13 Jun 2006
    30 Jan 2014
    Link to this post
    Hi,

    I'm trying to create a custom submit button for a built in form.

    I'm using this control:
    <sf:FormSubmitButton runat="server" ID="btSubmit" Text="Submit" CssClass="submitButton" /> 

    I need to attach a custom onclick attribute to the button for google event tracking. But I still need the onclick attribute given by the built in submit button for the form to return.

    The custom onclick attribute needs to be built up from fields in the widget designer and I have managed to get this working as follows:

    <input type="submit" name="ctl00$ctl00$cphBaseBody$LeftColumn$C001$ctl00$ctl00$C019$ctl00$ctl00$btSubmit" value="Submit" onclick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']);" id="cphBaseBody_LeftColumn_C001_ctl00_ctl00_C019_ctl00_ctl00_btSubmit" class="submitButton">

    This was done like this:

     protected override void InitializeControls(GenericContainer container)
            {
                this.btSubmit.Attributes.Add("onclick", string.Format("_gaq.push(['_trackEvent', '{0}', '{1}', '{2}']);", Category, Action, Label));

            }

    (where category, action and label are custom fields in the designer)

    However, I need the following onclick attribute for the form to go to the correct page when I hit submit:

    onclick="return Telerik.Sitefinity.Web.UI.Fields.FormManager.validateGroup(&quot;sf_getaquoteC005&quot;);" 

    How do I access that attribute?

    Kind regards,

    Sophie Baxter 
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    06 Dec 2016
    04 Feb 2014
    Link to this post
    Hello Sophie, 

    Subscribe to the click event of the form button using javascript widget placed on the page where the form is placed placing the below javascript in the javascript widget.

    In the javascritp widget please make sure to select the radio button option "Before the closing body tag"

    $('input[type=submit]').click(function() {
    //execute function here
    });


    Regards,
    Stanislav Velikov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered