0

I'm using jQuery Validation plugin to validate a WordPress theme form. I'm using also Bootstrap 4 so I'd integrate the Bootstrap validation classes ("is-valid" and "is-invalid") with Validation plugin, how can I do?

0

I found this solution:

$.validator.setDefaults({
    highlight: function (element, errorClass, validClass) {
        $(element).addClass('is-invalid');
    },
    unhighlight: function (element, errorClass, validClass) {
        $(element).removeClass('is-invalid');
    }
});

This is my previous personal solution:

signup_form.on( 'change submit', function( e ) {
    $( '.error' ).removeClass( 'is-valid' ).addClass( 'is-invalid' );
    $( '.valid' ).removeClass( 'is-invalid' ).addClass( 'is-valid' );
} );

Which is better?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy