WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Conditional Validation with jQuery? (2 posts)

  1. Casey Picker
    Member
    Posted 3 years ago #

    I was hoping to be able to do something like this to make another field required based on a drop-down value:

    $('select.previous').change(function(){
    	if($('select.previous').get(0).selectedIndex == 1) {
    		$('.otheraccount').addClass('wpcf7-validates-as-required');
    	} else {
    		$('.otheraccount').removeClass('wpcf7-validates-as-required');
    	}
    });

    The class is getting added, but CF7 isn't able to recognize it as required. Is this possible with jQuery?

  2. Casey Picker
    Member
    Posted 3 years ago #

    Has anyone else had any luck making a field required based on another field's drop-down value?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic