Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 input type number vs tel

I'm working on updating some form inputs to HTML5. I'm not interested in validating the data so much as having the numeric key pad on mobile devices. Input type 'tel' seems to do what I want, I get the numeric keypad on iPad/mobile. Input type 'number' will also give me the numeric keypad, but it also includes the spinner box which I don't want.

What I want to know is if it's safe to use type="tel" on a credit card input? Or should I use type="number" and try to disable the spinner somehow. I was reading that disabling the spinner can crash Chrome which isn't a trade off I'm willing to make.

Also, for the time being we're using the exact same site for mobile and non-mobile users.

like image 744
Tom Avatar asked Nov 21 '11 17:11

Tom


People also ask

Is Tel an input type?

The <input type="tel"> defines a field for entering a telephone number. Note: Browsers that do not support "tel" fall back to being a standard "text" input.

Can input type be number in HTML?

The <input type="number"> defines a field for entering a number. Use the following attributes to specify restrictions: max - specifies the maximum value allowed. min - specifies the minimum value allowed.

What is Tel in HTML?

< a href = "tel:123-456-7890" >123-456-7890</ a > Href=tel: creates the call link. This tells the browser how to use the number. “Tel: 123-456-7890 “creates the HTML phone number. The number within the quotes is the number it will call.

How do I limit a phone number in HTML?

You can specify a minimum length, in characters, for the entered telephone number using the minlength attribute; similarly, use maxlength to set the maximum length of the entered telephone number.


1 Answers

I looked at this and just tried this on my Xoom with the built in browser and FF mobile (with a desktop UA string) and the tel input would seem to work just fine for this.

screeny

like image 54
Eonasdan Avatar answered Oct 17 '22 08:10

Eonasdan