Yes, you can do that with custom HTML5 attribute pattern. Please follow the instructions here:
https://metabox.io/docs/custom-attributes-for-inputs/
Thread Starter
nepf
(@nepf)
Thank you,
but please help me again, i tried this
array(
'name' => 'subtitle',
'id' => $prefix . 'subt',
'type' => 'text',
'required' => true,
'regex' => '[1-9][a-d]',
),
what’s wrong?
There is no regex attribute. You should use pattern attribute. The format can be found at:
http://www.w3schools.com/tags/att_input_pattern.asp
Best regards
Anh
Thread Starter
nepf
(@nepf)
okey, so I tried
array(
'name' => 'subtitle',
'id' => $prefix . 'subt',
'type' => 'text',
'pattern' => '[1-9][a-d]',
),
the HTML-Source looks fine for me
<div class="rwmb-input">
<input id="px_subt" class="rwmb-text" type="text" name="px_subt" pattern="[1-9][a-d]" size="30">
</div>
but i don’t get any error-message for wrong inputs.
Just tested and found that the validation module doesn’t work well with pattern attribute. I’ve just pushed a fix on Github, please download the development version on Github and try again.
http://github.com/rilwis/meta-box/
Anh