How to add onclick attribute to the submit button?
I am trying to validate two email fields to make sure they are the same. I already have the folowing code on the page in a custom HTML block but I need to know how I add an onclick function to the submit button. There doesn't seem to be a way to add code to an actual form or submit element.
Re: How to add onclick attribute to the submit button?
There is some documentation on Marketo's Developer site about how to manipulate Form code. In order to add custom behavior you need to embed the Form 2.0 code on page and inject your custom script into it (all outlined in the documentation below).
Note the Marketo Forms 2.0 object model/API is an enhanced wrapper around a real HTML <FORM>. This is great because it allows you to use standard <FORM> behaviors (such as the native onSubmit event) and interrogate the form element in the DOM -- if absolutely necessary. However you should strive to use the supported Forms 2.0 API everywhere you can to avoid confusion.