Inbuilt form with custom forms widget + widget designer
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("sf_getaquoteC005");"
How do I access that attribute?
Kind regards,
Sophie Baxter
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
);