Title: &quot;Required&quot; setting
Last modified: August 30, 2016

---

# "Required" setting

 *  Resolved [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/)
 * I am sorry if this is discussed somewhere but I was not able to find it.
 * Is there a way to make a field “required” so that a user has to fill it in before
   the post can be saved?
 * Thank you ahead of time.
 * [https://wordpress.org/plugins/meta-box/](https://wordpress.org/plugins/meta-box/)

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

 *  Plugin Contributor [Manny Fleurmond](https://wordpress.org/support/users/funkatronic/)
 * (@funkatronic)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399027)
 * You can add validation rules to your meta box to specify features for individual
   fields, including whether or not a field is required. Notice the code in the 
   demo file here: [https://github.com/rilwis/meta-box/blob/d3d89945e60c464b9a6b9ecf5fcebcffe9782012/demo/demo.php#L130](https://github.com/rilwis/meta-box/blob/d3d89945e60c464b9a6b9ecf5fcebcffe9782012/demo/demo.php#L130)
 *  Thread Starter [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399031)
 * Hi Manny,
 * Thanks for your response.
 * I did notice that validation example, but it seems to be for adding a password.
 * I am more looking for simply a “required” setting.
 * Is there an example anywhere of how to do that?
 *  Plugin Contributor [Manny Fleurmond](https://wordpress.org/support/users/funkatronic/)
 * (@funkatronic)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399032)
 * The validation example I linked does show how to do a required field. Look at
   line 140
 *  Thread Starter [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399033)
 * Please look at the context of that line:
 * Line 137: // optional override of default jquery.validate messages
 * Line 140: ‘required’ => __( ‘Password is required’, ‘your-prefix’ ),
 * In other words line 140 specifies text to over-ride the standard text associated
   with the password.
 * Furthermore, the above lines are a subset of:
 *  ‘rules’ => array(
    “{$prefix}password” => array( ‘required’ => true, ‘minlength’
   => 7,
 * Which specifies a password, and has nothing to do with specifying a “required”
   setting.
 * Just because you see “required” a bunch of times in some code does not mean it
   has anything to do with setting a “required” validation to a field.
 * Furthermore, there is nothing I can find in that whole file that has anything
   to do with setting “required”.
 *  Plugin Contributor [Manny Fleurmond](https://wordpress.org/support/users/funkatronic/)
 * (@funkatronic)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399034)
 * Sorry, wrong line of code. password is the name of one of the fields. I’ve editted
   the code to make more sense:
 *     ```
       'validation' => array(
       	'rules'    => array(
       		"myfavecolor" => array(
       			'required'  => true,
       		),
       	),
       	// optional override of default jquery.validate messages
       	'messages' => array(
       		"myfavecolor" => array(
       			'required'  => __( 'Field is required', 'your-prefix' ),
       		),
       	)
       )
       ```
   
 * The validation code creates a rule that makes the field of name `myfavcolor` 
   required. The messages part is the message that is displayed if the user leaves
   the field blank
 *  Thread Starter [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399053)
 * Thanks for adding that 🙂

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

The topic ‘"Required" setting’ is closed to new replies.

 * ![](https://ps.w.org/meta-box/assets/icon-128x128.png?rev=1100915)
 * [Meta Box](https://wordpress.org/plugins/meta-box/)
 * [Support Threads](https://wordpress.org/support/plugin/meta-box/)
 * [Active Topics](https://wordpress.org/support/plugin/meta-box/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/meta-box/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/meta-box/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/required-setting/#post-6399053)
 * Status: resolved