Validation not working on FIle or File Advanced Field

Support General Validation not working on FIle or File Advanced Field

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3521
    WebbioWebbio
    Participant

    Metabox Version 4.8.7
    I want File field required but the validation is only working of INPUT fields not for File Type or File Upload Field http://i.imgur.com/DP5Wbnq.png

    
        $meta_boxes[] = array(
            // Meta box id, UNIQUE per meta box. Optional since 4.1.5
            'id'         => 'standard',
            // Meta box title - Will appear at the drag and drop handle bar. Required.
            'title'      => esc_html__( 'Standard Fields', 'your-prefix' ),
            // Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.
            'post_types' => array( 'post', 'page' ),
            // Where the meta box appear: normal (default), advanced, side. Optional.
            'context'    => 'normal',
            // Order of meta box: high (default), low. Optional.
            'priority'   => 'high',
            // Auto save: true, false (default). Optional.
            'autosave'   => true,
            // List of meta fields
            'fields'     => array(
                array(
                    'name' => esc_html__( 'Image', 'your-prefix' ),
                    'id'   => "{$oyeprefix}file1",
                    'type' => 'file',
                    'max_file_uploads' => 1
                ),
             
            ),
            'validation' => array(
                'rules'    => array(
                    "{$oyeprefix}file1" => array(
                        'required'  => true,
                    ),
                ),
                // optional override of default jquery.validate messages
                'messages' => array(
                    "{$oyeprefix}file1" => array(
                        'required'  => esc_html__( 'File is required', 'your-prefix' ),
                    ),
                ),
            ),
        );
    
    #3525
    Anh TranAnh Tran
    Keymaster

    Sorry, the validation hasn't worked for media fields for now :(. We use complicated JS to handle upload/insert files and generate the HTML dynamically. That makes the validation JS not work 🙁

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.