• Hi,

    I have a script on my website that seems to stop working. When testing the wpcf7-not-valid class seems to be added after wpcf7invalid runs.

    Here is a copy of the script:

    $(function () {
    $(document).on('wpcf7invalid', function(event) {
    for (let i = 0; i < event.target.elements.length; i++) {
    console.log(event.target.elements[i].classList);
    // console.log(event.target.elements[i].classList.contains('wpcf7-not-valid'));

    if (event.target.elements[i].classList.contains('wpcf7-not-valid') !== false) {
    $(event.target.elements[i]).addClass('is-invalid');
    }
    }
    });

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter Cozmoz365

    (@cozmoz365)

    I’ve added this as a temporary fix:

    $(document).on('wpcf7invalid', function(event) {
    setTimeout(function() {
    $('.wpcf7-form').find('.wpcf7-not-valid').closest('label').addClass('is-invalid');
    $('.wpcf7-form').find('.wpcf7-not-valid').addClass('is-invalid');
    }, 500);
    });
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.