Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine pattern with maxlength of input field

Is it possible to combine a pattern attribute with a maxlength attribute on an input field in jquerymobile?

<input name="aNumber" type="number" pattern="[0-9]{6}" maxlength="6" placeholder="dddddd" value="">
<input name="anotherNumber" type="number" pattern="[0-9]{3,4}" maxlength="4" placeholder="ddd(d)" value="">

I want the big numberpad to appear but that only works using pattern="[0-9]*". Unfortunately the maxlength attribute is not respected in any case.

What I want is a numeric keypad to appear (the big one/dial; the iPhone apparently has two: only numbers/dial and numbers with special chars) letting the user input up to 6 or 3 to 4 numeric chars.


Edit: Applied @raina77ow 's suggestion and that works for the moment, but still it feels not right so I'm open to advice!

<input name="aNumber" type="tel" pattern="[0-9]*" maxlength="6" placeholder="dddddd" value="">
like image 298
mayrs Avatar asked Sep 01 '25 03:09

mayrs


1 Answers

{6} means exactly 6 Digits {0,6} means minimum 0 digits and maximum 6 digits

like image 99
user3282837 Avatar answered Sep 02 '25 18:09

user3282837