Stopping a lightbox form submission is useful in order to validate that the input fields have appropriate values.
In the Custom JS (Boxes), there are a few Event Triggers where this can be accomplished.
- Before form validation
- After form validation
- Before submit
These three Event Triggers are unique from all the other ones. They allow you to return different "types" to achieve different results. Specifically, if you return one of the following statements.
Returning false simply halts execution and prevents the form from being submitted. If you return false for the Event Trigger Before Form Validation then the normal validation will not run and the form will not be submitted. But if you return false After Form Validation then the normal validation will run, but your custom js function will only run if it makes it past the normal validation. But if it makes it that far, since you are returning false, it will halt execution and the form will not be submitted. And finally, if you return false Before Submit then the normal validation will run, but the form will not be submitted.
return "some error message"
In this case, if you return a string, it will be displayed as an error message. This is a way to display a custom validation failure message. It works exactly like returning "false" above. But in this case, it also displays an error message to the user.
x.custom_1 = "some_random_pw";
x.additional_field = "anything";
In the example above, x is modified and then returned. When you return an object like this, it instructs the form submission process to use that object instead of the original form data object.
return true or return
This type of return value will allow the Primer widget to continue with the normal flow of the form submission process.