Custom Form Navigation Using JavaScript

In this guide, we will add custom navigation to our form pages with JavaScript. This will allow us to run custom logic before navigating users to the next page or submitting the form.

First, we will need to disable standard navigation on the form using the form builder setup.

image

Triggering default form navigation actions using JavaScript.

// Set navigation type from the following - back, next, cancel, draft, finish
var navigation_type = 'next';
// Create and trigger a hidden navigation button
$( '<input>' ).attr( {
	type: 'hidden',
	class: navigation_type,
	'data-go_to_page': ''
} ).appendTo( '#component_list' ).trigger( 'click' );

You can add custom buttons on your form for data validation before moving to the next page or submitting the form.

<button id="next_with_validation" class="btn btn-lg btn-block btn-default">Next</button>

<button id="submit_with_validation" class="btn btn-lg btn-block btn-success">Submit</button>

Using JavaScript you can listen to the custom button click and run custom validation before allowing users to navigate.

Standard navigation button example using HTML field. These buttons can also be dynamically added to the page using JavaScript.

You can add other custom HTML components using theย Bootstrap CSS library - https://getbootstrap.com/docs/3.4/components/

For any questions, please contact us at [email protected] or the Formyoula in-app chat ๐Ÿ™‚