• Hy,
    First of all, compliments for the great plugin.
    I tried to set the field “start” as required when the value of the field “jahrgang” is smaler than 2005.

    As the field “jahrgang” has many values to be selected, so I tried the solution with jQuery.

    jQuery(function($){
    $(‘#jahrgang’).on(‘change’, function() {
    if(this.value <= 2005){
    $(‘#start’).attr(“aria-required”, “true”);
    $(‘#start’).addClass(“wpcf7-validates-as-required”);
    }else{
    $(‘#start’).removeAttr(‘aria-required’);
    $(‘#start’).removeClass(“wpcf7-validates-as-required”);
    }
    })
    });

    Unfortunately this code doesn’t work…

    Would be very grateful if there would be a solution with jQuery.

    Thanks and best reguards!
    Peter

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

The topic ‘Set a field as required with jQuery’ is closed to new replies.