Miran Legin• 620
@miranlegin
Posted
Hi Yunus,
regarding input fields you can do some improvements
- use appropriate input types for form fields MDN documentation on Input Types especially for mobile users because keyboard is different for every input type
- for numbers you can go with both
input type="number"
orinput type="tel"
, there are couple of differences though so you can explore more on the link - also there is a way to limit number of characters in form fields with
maxlength
atribute; for examplemaxlength="2"
- for MM field you know the minimum and maximum values accepted so you can add
min
ormax
attributes aswell - another attribute worth considering is
pattern
where you can specify accepted values as a regex pattern; for examplepattern=="[0-9]{1,2}"
Before: <input type="text" class="form-control" id="month" placeholder="MM" autocomplete="off">
After: <input type="number" maxlength="2" min="1" max="12" pattern=="[0-9]{1,2}" title="Only numbers from 1 to 12" placeholder="MM">
Keep coding!
Marked as helpful
0
Yunus Emre Çınar• 360
@Yunuscinar41
Posted
@miranlegin I searched about the pattern but I only found js ones. Thanks!
0