Input Attributes: "pattern" not working

Support Meta Box AIO Input Attributes: "pattern" not workingResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29932
    team@novify.pt[email protected]
    Participant

    I'm registering a field group for a CPT and can't have the pattern attribute working. No validation happens on the backend or frontend, Chrome or Firefox. I went back to the basics and created a new group with only one field following the example shown in the documentation and still does not work. Here's the code:

    add_filter( 'rwmb_meta_boxes', 'nvf_register_mb_candidatura_form_input' );
    
    function nvf_register_mb_candidatura_form_input( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Input Formulário dev', 'nvf-gb-front' ),
            'id'         => 'candidatura-form-details-dev',
            'post_types' => ['candidatura_bolsa'],
            'fields'     => [
                [
                    'type' => 'text',
                    'id'   => 'phone',
                    'name' => 'Phone number',
                    
                    // Attributes for validation.
                    'required' => true,       // Make the field required.
                    'pattern'  => '[0-9]{9}', // Must have 9 digits
                ]
            ],
        ];
    
        return $meta_boxes;
    }

    Any ideas of what can be going on?

    Thanks in advance.

    EDIT: I'm using MB AIO Version 1.14.3 and MB Version 5.4.6

    #29944
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for your feedback.

    Please add the attribute pattern in attributes setting like this

    // Attributes for validation.
    'required' => true,       // Make the field required.
    'attributes' => [
        'pattern'  => '[0-9]{9}', // Must have 9 digits
    ]

    I will inform the development team to check the issue with the global attributes.

    #30683
    team@novify.pt[email protected]
    Participant

    Hi, this solved the issue.

    Thanks a lot.

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