Add custom class to form when it’s succesfully validated

Home Forums Jquery Validation For Gravity Forms Add custom class to form when it’s succesfully validated

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #483262
    Robby Geybels
    Participant

    Hi Dinesh, Is there a way to add a specific class to the GravityForms form when it has succesfully validated all the necessary fields? The reason behind this is that I would like to color the gform submit button green when all (required) fields are filled in correctly.

    At first I thought I’ve fixed this by using the jQuery valid() method like this:

    jQuery(function ($) {
    $(window).on(‘load’, _ => {
    $(‘.gform_wrapper form’).each((_, formElement) => {
    let $form = $(formElement)
    $form.on(‘change keyup’, e => {
    $form.toggleClass(‘is-valid’, !!$form.valid())
    })
    })
    })
    })

    The only problem is that when the first required field is filled in all the other required fields in the same form are getting marked as invalid. Any tips or tricks to help me out? Thank you in advance!

    #483291
    Dinesh
    Keymaster

    Hi Robby,

    Can you please check this thread. https://github.com/jquery-validation/jquery-validation/issues/1996

    Hope this helps.

    Thanks

    #483330
    Robby Geybels
    Participant

    Hi Dinesh,

    Thank you for the quick reply and suggestion. The provided solutions found in that thread are not working either. These scripts also trigger a validation to all the form fields when using the .valid() method. Is there a way to trigger a validation on only the current field thats getting filled in?

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Add custom class to form when it’s succesfully validated’ is closed to new replies.