tag to prevent default submission, compare input to your target string (e.g., "ACCESS123"), and display the appropriate message based on the match.
You can successfully implement custom form validation in Webflow where an input must match a specific value, using a combination of Webflow's native structure and a small amount of custom JavaScript for condition-based messaging.
secret-code
).Go to Page Settings where the form exists.
Paste the following JavaScript inside the Before tag section:
Inline explanation:
This script prevents normal form submission.
It checks if the input value equals "ACCESS123".
If it matches, it shows the success message.
If not, it shows the error message.
JavaScript reference (do not copy raw code per guideline):
Use document.querySelector
to capture the form and input.
Use e.preventDefault()
in the submit event listener.
Compare input.value
to your expected string.
Use form.querySelector('.w-form-done')
and .w-form-fail
to toggle messages.
To implement keyword-based input validation in Webflow, you need to combine native form structure with a small JavaScript snippet that compares the input value to your target string, then dynamically show success or error messages. This approach gives full control over conditional messaging without needing third-party tools.