samedi 28 février 2015

Enforce numerics only in input text field with dashes (serial key, credit card number)

I have a field that takes in numerics in the following format XX-XXXX-XXXX-XXXX and I was wondering what would be the best modern approach to enforce the user only enters numbers?


My current solution consists of four input fields with dashes in between them to guide the user but this seems a little outdated, I want to use what HTML5 has to offer.


A good example I can think of is the old CD keys when installing software. As you enter enough digits it will focus on the next group. Is there any way I can do this without breaking out a JS solution?


EDIT: When I say "enforce" what I mean is when the user enters anything other than numerics nothing will happen.


Aucun commentaire:

Enregistrer un commentaire