Title: [Plugin: Contact Form 7] Conditional Validation with jQuery?
Last modified: August 19, 2016

---

# [Plugin: Contact Form 7] Conditional Validation with jQuery?

 *  [ckpicker](https://wordpress.org/support/users/ckpicker/)
 * (@ckpicker)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-validation-with-jquery/)
 * 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?

Viewing 1 replies (of 1 total)

 *  Thread Starter [ckpicker](https://wordpress.org/support/users/ckpicker/)
 * (@ckpicker)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-validation-with-jquery/#post-2038938)
 * Has anyone else had any luck making a field required based on another field’s
   drop-down value?

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Contact Form 7] Conditional Validation with jQuery?’ is closed
to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [ckpicker](https://wordpress.org/support/users/ckpicker/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-contact-form-7-conditional-validation-with-jquery/#post-2038938)
 * Status: not resolved