I'm trying to get regex pattern in input type number to show only numbers and forward slash. I tried something like this.
<input type="number" pattern="[0-9\/]*">
But getting only 0-9 number pad. How can I show 0-9 number pad as well as forward slash "/"
in regex.
I'm trying to get regex pattern in input type number to show only numbers and forward slash. I tried something like this.
<input type="number" pattern="[0-9\/]*">
But getting only 0-9 number pad. How can I show 0-9 number pad as well as forward slash "/"
in regex.
- it is not semantically correct to use an input with a number type and requesting a non-number value. – Gaël Barbin Commented Apr 13, 2015 at 10:28
- then do u have anything with javascript? – UI_Dev Commented Apr 13, 2015 at 10:36
- 1 I did not understand you were looking for to select a mobile virtual keyboard – Gaël Barbin Commented Apr 13, 2015 at 11:09
2 Answers
Reset to default 2You could use input type "text" for only the validation purpose.
<input type="text" pattern="[0-9\/]*" >
You can consider the "tel" input type, for a simpler keybord layout containing the slash on a mobile device
<input type="tel" pattern="[0-9\/]*">
You should change the input type to text
:
<input type="text" pattern="[0-9\/]*" name="text_with_numbers">
See more information here.