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.
1) Before Form Validation
2) After Form Validation
3) Before Submit
These 3 Event Triggers are unique from all the other ones. These 3 allow you to return different "types" to achieve different results. Specifically, if you return one of the following statements.
1) return false;
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.
2) 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.
3) return anObject;
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.
– or –
This type of return value will allow the Primer widget to continue with the normal flow of the form submission process.
Please sign in to leave a comment.