Skip to content

Show a form field error message #965

Answered by engram-design
roland-d asked this question in Q&A
Discussion options

You must be logged in to vote

It's a bit of a pain with bouncer.js in that you need to register your own custom validator so that it knows about it ahead of time. It's a little more work, but it's not too difficult and is a little more robust.

const $form = document.querySelector('.fui-form');

$form.addEventListener('registerFormieValidation', function(e) {
    const customRule = {
        myCustomRule(field) {
            // Only apply this rule for the field we want to target.
            // Could be using a data-attribute, CSS selector, whatever you need
            if (field.getAttribute('name') != 'fields[emailAddress]') {
                return;
            }

            // Add your logic here, return `true` w…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@roland-d
Comment options

@roland-d
Comment options

@engram-design
Comment options

Answer selected by roland-d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants