Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Numeric only text field lets letters through

$
0
0

Replies: 0

Following the instructions here https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#limit-text-field-to-numbers-only

I’ve set a text field to numeric, but when testing, I typed in letters instead of numbers and they were allowed through.

$cmb->add_field( array(
‘name’ => __( ‘price for 1 license’, wds-post-submit ),
‘id’ => $prefix . ‘price_for_1_license’,
‘type’ => ‘text’,
‘type’ => ‘number’,
‘attributes’ => array(
‘type’ => ‘number’,
‘pattern’ => ‘\d*’,
),
) );

And here is the result: price_for_1_license is “aaaaaaa”, even though it should not allow letters. Unless it works with hex numbers? 😛


Viewing all articles
Browse latest Browse all 59525

Trending Articles