Support Forum
Support › Meta Box Builder › HTML Type pattern="d{3}-d{3}-d{3}Resolved
I added a "text field" to custom fields group and in the advanced-tab of it I added a "custom attributes" and filled the two fields with "pattern" and "d{3}-d{3}-d{3}".
But by entering 123-123-123 in admin an error shows up: Invalid format.
What is missing or wrong?
Hi,
You can use this pattern to validate 3 numbers and a hyphen between [0-9]{3}-[0-9]{3}-[0-9]{3}
. See more on this guide: https://www.html5pattern.com/Postal_Codes.
Unfortunately also not working (same error-message / red field) - please can you show an example of how it works in the graphical UI?
As no pictures are possible to add, I can not show the result - only describe it...
I am doing it in "Taxonomies = category".
Copde generated:
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => esc_html__( 'Category_Order', 'text-domain' ),
'id' => 'Category_order',
'fields' => [
[
'id' => $prefix . 'M_category-orderID',
'type' => 'number',
'name' => esc_html__( 'Category Order ID', 'text-domain' ),
'required' => 1,
'tooltip' => 'defines order priority',
'admin_columns' => [
'position' => 'before name',
'sort' => true,
],
],
[
'id' => $prefix . 'text_sb532j9yqc',
'type' => 'text',
'name' => esc_html__( 'Text Field', 'text-domain' ),
'pattern' => '[0-9]{3}-[0-9]{3}-[0-9]{3}',
],
],
'taxonomies' => ['category'],
];
return $meta_boxes;
}
Hi,
The pattern in your code works as well on my local site, see this screen record https://share.getcloudapp.com/wbuKO5B5.
Please try to check this case in another browser such as Edge or Firefox.
Can be closed, thanks.