Skip to content

How to create a button that runs JavaScript before submitting

davidstillwell edited this page Dec 21, 2016 · 1 revision

If you put a button on a page, Concerto automatically submits the page when the button is pressed. This is normally what you want, except if you want to run some JavaScript before the page is submitted. For example, if you have some form inputs and you want to do validation on them before submitting the page.

You can achieve this by adding the class "concerto-nosubmit" to the form button, like so:

<button class="concerto-nosubmit" name="mybutton">My Button</button>

After doing your validation, you can also submit the form from JavaScript with the following JS code:

testRunner.submitView("buttonName", false);

Clone this wiki locally