[html5] Select API for inputs of type numer and email.

Ian Hickson ian at hixie.ch
Tue Mar 4 20:01:13 PST 2014


On Thu, 27 Feb 2014, Kevin Sheedy wrote:
> 
> The Chrome browser recently disabled the *select api* for inputs of type
> number and email:
> https://codereview.chromium.org/100433008/#ps60001
> 
> The select api is a collection of attributes and functions that allow us to
> get and set which portion of text a user has highlighted in an <input>
> 
> The attributes and functions in question are:
> select()
> selectionStart
> selectionEnd
> selectionDirection
> setRangeText()
> setSelectionRange()
> 
> This change caused bugs in several libraries:
> 
> http://stackoverflow.com/questions/21177489/selectionstart-selectionend-on-input-type-number-no-longer-allowed-in-chrome#
> 
> https://github.com/KevinSheedy/jquery.alphanum/issues/19
> 
> The spec says that these properties should be available for inputs of 
> types* text, search, url, telephone and password* but not for inputs of 
> type *number or email.*
> 
> I'd like to request that this collection also be made available to 
> inputs of type number and email.
> 
> Does anyone have any insight as to why these types were excluded?

There's been some discussion of this here:

   https://www.w3.org/Bugs/Public/show_bug.cgi?id=24796

The short answer is that the selection APIs don't apply here because 
there's no way to know what you're going to be selecting. If the value is 
"123456", and you select characters 1 through 4, what is selected?

Is it "1[23,4]56" ? (square brackets showing selection)

Is it "O[ne h]undred and twenty three thousand, four hundred and fifty 
six"?

Is it "0[00'1]23'456" ?

Is it "1[.234]56e5" ?

All of these are valid things for the browser to be showing in a numeric 
field. Indeed, the browser could also show them as even more elaborate 
controls, say as:

 [+] ..... ..... ..... ..... ..... ..... .....
     |   | | 0 | | 1 | | 2 | | 3 | | 4 | | 5 |
  >> |   | | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | <<
     |   | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 |
     ''''' ''''' ''''' ''''' ''''' ''''' ''''' [.]

...or as:

  0                100k              200k
  |----------------------v-------------|
                      123,456

How would you select anything there?

This is why the API doesn't apply.

So far, the use cases revolve mostly around doing things that shouldn't be 
necessary, like doing a fake JS-based keyboard for kiosks, instead of 
using native kiosk soft-keyboards provided by the OS. These really aren't 
use cases that make sense for the Web -- the whole point of the Web's 
design is that if you want a special input mode, like a software keyboard, 
you provide that at the user agent (browser) level, not in the page.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the Help mailing list