HTML5 input inputmode All In One

inputmode 是一种自动适配虚拟键盘类型的增强模式, 不是用来 代替 input type 输入框的!

The inputmode global attribute is an enumerated attribute that hints at the type of data that might be entered by the user while editing the element or its contents.
This allows a browser to display an appropriate virtual keyboard.

inputmode 全局属性是一个枚举属性,它提示用户在编辑元素或其内容时可能输入数据类型
这允许浏览器显示适当的虚拟键盘

It is used primarily on <input> elements, but is usable on any element in contenteditable mode.

它主要用于 <input> 元素,但可用于任何处于 contenteditable 模式的元素。

It’s important to understand that the inputmode attribute doesn’t cause any validity requirements to be enforced on input.
To require that input conforms to a particular data type, choose an appropriate <input> element type.

重要的是要了解 inputmode 属性不会导致对输入强制执行任何有效性要求。
要要求输入符合特定数据类型,请选择适当的 <input> 元素类型。

  1. none
  2. No virtual keyboard.
  3. For when the page implements its own keyboard input control.
  4. text (default value)
  5. Standard input keyboard for the user's current locale.
  6. decimal
  7. Fractional numeric input keyboard containing the digits and decimal separator for the user's locale (typically . or ,).
  8. Devices may or may not show a minus key (-).
  9. numeric
  10. Numeric input keyboard, but only requires the digits 09.
  11. Devices may or may not show a minus key.
  12. tel
  13. A telephone keypad input, including the digits 09, the asterisk (*), and the pound (#) key.
  14. Inputs that *require* a telephone number should typically use <input type="tel"> instead.
  15. search
  16. A virtual keyboard optimized for search input.
  17. For instance, the return/submit key may be labeled "Search", along with possible other optimizations.
  18. Inputs that require a search query should typically use <input type="search"> instead.
  19. email
  20. A virtual keyboard optimized for entering email addresses.
  21. Typically includes the @character as well as other optimizations.
  22. Inputs that require email addresses should typically use <input type="email"> instead.
  23. url
  24. A keypad optimized for entering URLs. This may have the / key more prominent, for example.
  25. Enhanced features could include history access and so on.
  26. Inputs that require a URL should typically use <input type="url"> instead.

  1. <section>
  2. <h2>input inputmode</h2>
  3. <input inputmode="text"><span>input inputmode="text", default</span><br/>
  4. <input inputmode="none"><span>input inputmode="none"</span><br/>
  5. <input inputmode="decimal"><span>input inputmode="decimal"</span><br/>
  6. <input inputmode="numeric"><span>input inputmode="numeric"</span><br/>
  7. <input inputmode="tel"><span>input inputmode="tel"</span><br/>
  8. <input inputmode="search"><span>input inputmode="search"</span><br/>
  9. <input inputmode="url"><span>input inputmode="url"</span><br/>
  10. <input inputmode="email"><span>input inputmode="email"</span><br/>
  11. </section>
  1. <section>
  2. <h2>input type</h2>
  3. <input type="text"><span>input type="text", default</span><br/>
  4. <input type="button" value="value is button"><span>input type="button"</span><br/>
  5. <input type="checkbox"><span>input type="checkbox"</span><br/>
  6. <input type="color"><span>input type="color"</span><br/>
  7. <input type="date"><span>input type="date"</span><br/>
  8. <input type="datetime-local"><span>input type="datetime-local"</span><br/>
  9. <input type="email"><span>input type="email"</span><br/>
  10. <input type="file"><span>input type="file"</span><br/>
  11. <input type="hidden"><span>input type="hidden"</span><br/>
  12. <input type="image" src="https://cdn.xgqfrms.xyz/logo/icon.png" width="50px"><span>input type="image"</span><br/>
  13. <input type="month"><span>input type="month"</span><br/>
  14. <input type="number"><span>input type="number"</span><br/>
  15. <input type="password"><span>input type="password"</span><br/>
  16. <input type="radio"><span>input type="radio"</span><br/>
  17. <input type="range"><span>input type="range"</span><br/>
  18. <input type="reset"><span>input type="reset"</span><br/>
  19. <input type="search"><span>input type="search"</span><br/>
  20. <input type="submit"><span>input type="submit"</span><br/>
  21. <input type="tel"><span>input type="tel"</span><br/>
  22. <input type="time"><span>input type="time"</span><br/>
  23. <input type="url"><span>input type="url"</span><br/>
  24. <input type="week"><span>input type="week"</span><br/>
  25. <p>Obsolete values / 过时的值 ❌</p>
  26. <input type="datetime"><span>input type="datetime"</span><br/>
  27. </section>
  1. <section>
  2. <h2>contenteditable="true"</h2>
  3. <div contenteditable="true">div contenteditable="true"</div>
  4. <span>div contenteditable="true"</span><br/>
  5. </section>

See the Pen
html5 input inputmode All In One
by xgqfrms (@xgqfrms)
on CodePen.

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable