Meta box Custom Validation Not working
-
In the latest version there is a new ‘validation’ meta-box argument that allows specifying validation rules and messages using jquery.validate syntax. I tried this for my project. But it is not worked for me, I want to know is there anything that, I should include other than the plugin? This is my code:
function end_user_register_meta_boxes( $meta_boxes ) { $prefix = 'end_user_alameda_'; $meta_boxes[] = array( 'id' => 'standard', 'title' => __( 'End User', 'rwmb' ), 'pages' => array( 'end_user' ), 'context' => 'normal', 'priority' => 'high', 'autosave' => true, 'fields' => array( array( 'name' => __( 'Email', 'rwmb' ), 'id' => "user_email", 'type' => 'email', ), array( 'name' => __( 'Password', 'rwmb' ), 'id' => "user_password", 'type' => 'password', ), array( 'name' => __( 'Loyalty', 'rwmb' ), 'id' => "user_loyalty", 'type' => 'text', ), ), 'validation' => array( 'rules' => array( "password" => array( 'required' => true, 'minlength' => 7, ), ), // optional override of default jquery.validate messages 'messages' => array( "password" => array( 'required' => __( 'Password is required', 'meta-box' ), 'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ), ), ) ) ); return $meta_boxes; }
When I click on update/publish even without type the password, It updating. No Validation messages appearing. I’m confused what is wrong in my code. Please help me guys.
Regards,
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Meta box Custom Validation Not working’ is closed to new replies.