Trigger an action when a form entry is changed by a user. Such as validating the data or checking the value against an answer.
The following code allows you to do something based on a form field being updated. The code first selects the form field you’re interested in by specifying the name of the form and the field name you’re interested in (here we’ve used ‘my-form’ and ’email-address’). You can find and edit these in the form components settings in Fliplet Studio.
JavaScript
Fliplet.FormBuilder.get('my-form')
.then(function (form) {
form.field('email-address').change(function (val) {
// Any code here will be run every time a user updates the email-address field
// The value of the updated field entry is stored in the ‘val’ variable which you can use in your code.
}, false); // Set to false to prevent this code from running on form initialization
});
The above is triggered as soon as the email-address field is modified. The example code provides you with the value of the modified field (called ‘val’ in the code above). You could check if the value is a valid email address and display a message to the user if it isn’t.