@flo got back to me on this one and says you can do it if you trigger the workflow on click on the button element (instead of on submit on the form container element).
You would then need to manage the verification of input fields manually with actions so it would be a lot of work
I’ve added your question to our user research so we keep it in mind when exploring new functionalities like multi-branching and adding a throw error action.
I ended up just using inline error messages that show an error message below the input field after a user clicks on the submit button, if the field is invalid.
Here is my solution incase anyone else is looks at this later on:
You cannot put the workflow in onSubmit as the actions will not run in the workflow if there are invalid inputs
I put the javascript in the onClick workflow for a SUBMIT button.
add an HTML Attribute to all of the fields that you want to be validated with key = validate_input
Add an empty text element below the input element with an HTML attribute with key = error_for, and value = ##The name of the field this is an error message for##
This is the javascript in the workflow, onSubmit action:
var valid = true, error = "", field = "", form = "", invalid_inputs = [];
form = document.getElementById("page2-form");
form.querySelectorAll('[validate_input]').forEach(element => {
field = element;
error = document.querySelectorAll('[error_for=' + field.name + ']');
if (!field.checkValidity()) {
valid = false;
field.classList.add("input_error");
error[0].innerHTML = field.validationMessage;
// invalid_inputs.push(field); use this is if you want collect the list of input fields that have errors to show a summary meesage.
} else {
field.classList.remove("input_error");
error[0].innerHTML = "";
}
});
return valid; // you can use this in the next action for your form submit step