Title: Do not validate hidden required fields
Last modified: September 1, 2016

---

# Do not validate hidden required fields

 *  Resolved [kkmachado](https://wordpress.org/support/users/kkmachado/)
 * (@kkmachado)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/do-not-validate-hidden-required-fields/)
 * Hello,
 * I’m build a form and some fields need to be hidden according the other fields
   answer. The problem is the form doesn’t validate as these fields are required.
   How can I disable validate when a field is hidden?
 * I’m use jQuery to show/hide fields.
 * Thanks
 * [https://wordpress.org/plugins/profile-builder/](https://wordpress.org/plugins/profile-builder/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Razvan Mocanu](https://wordpress.org/support/users/razvanmo-1/)
 * (@razvanmo-1)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/do-not-validate-hidden-required-fields/#post-7526835)
 * Hi,
 * You can use filter on the checking of the required fields.
    There you can add
   a condition for the “maybe required” field so that it takes into account the 
   value from the decisive field. The hook to be used depends on the type of field
   that is hidden.
 * For example, for the field of type Input:
 *     ```
       /* handle field validation */
       function wppbc_check_input_value( $message, $field, $request_data, $form_location ){
       	remove_filter('wppb_check_form_field_input', 'wppb_check_input_value', 10);
       	if( $field['field'] == 'Input' ){
       		if( $field['required'] == 'Yes' ){
       			if( !($field['meta-name'] == "maybe_hidden_custom_field" && $request_data['decisive_field'] == "Make fields below unrequired")) {
       				if ((isset($request_data[wppb_handle_meta_name($field['meta-name'])]) && (trim($request_data[wppb_handle_meta_name($field['meta-name'])]) == '')) || !isset($request_data[wppb_handle_meta_name($field['meta-name'])])) {
       					return wppb_required_field_error($field["field-title"]);
       				}
       			}
       		}
       	}
   
       	return $message;
       }
       add_filter( 'wppb_check_form_field_input', 'wppbc_check_input_value', 5, 4 );
       ```
   
 * The function returns a special error message, if the field is required.
    The 
   meta-names of the fields are _maybe\_hidden\_custom\_field_ and _decisive\_field_.
 *  Thread Starter [kkmachado](https://wordpress.org/support/users/kkmachado/)
 * (@kkmachado)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/do-not-validate-hidden-required-fields/#post-7526840)
 * Hi there!
 * I’m going to try it.
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Do not validate hidden required fields’ is closed to new replies.

 * ![](https://ps.w.org/profile-builder/assets/icon-256x256.png?rev=2961144)
 * [User Profile Builder - Beautiful User Registration Forms, User Profiles & User Role Editor](https://wordpress.org/plugins/profile-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/profile-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/profile-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/profile-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/profile-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/profile-builder/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [kkmachado](https://wordpress.org/support/users/kkmachado/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/do-not-validate-hidden-required-fields/#post-7526840)
 * Status: resolved