HTML Type pattern="d{3}-d{3}-d{3}
Support › MB Builder › HTML Type pattern="d{3}-d{3}-d{3}Resolved
- This topic has 4 replies, 2 voices, and was last updated 5 years ago by
jw_bln.
-
AuthorPosts
-
January 6, 2021 at 10:45 PM #23867
jw_bln
ParticipantI 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?
January 7, 2021 at 6:00 AM #23872Long Nguyen
ModeratorHi,
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.January 7, 2021 at 4:44 PM #23890jw_bln
ParticipantUnfortunately 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; }January 8, 2021 at 6:14 PM #23922Long Nguyen
ModeratorHi,
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.
January 29, 2021 at 1:02 AM #24219jw_bln
ParticipantCan be closed, thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.