[HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法

在「[HTML5] 強制 input 只能輸入數字、指定type=number 與 pattern=[0–9]是不足的」的文章中我們針對 PC 實作了客制化的 sanitize 方法讓 input 輸入欄只能接收數字。而對於行動裝置我們也知道了只使用 HTML type=”number” 是不夠的,需要再加上 inputmode=”numeric”, pattern=”[0-9]*” 才能 100% 的讓所有 iOS, Android 裝置正確地顯示數字鍵盤,否則部份的手機裝置仍會顯示「字母+數字」…


This content originally appeared on DEV Community and was authored by Kueiapp

在「[HTML5] 強制 input 只能輸入數字、指定type=number 與 pattern=[0–9]是不足的」的文章中我們針對 PC 實作了客制化的 sanitize 方法讓 input 輸入欄只能接收數字。而對於行動裝置我們也知道了只使用 HTML type="number” 是不夠的,需要再加上 inputmode="numeric", pattern="[0-9]*" 才能 100% 的讓所有 iOS, Android 裝置正確地顯示數字鍵盤,否則部份的手機裝置仍會顯示「字母+數字」的鍵盤並且會接受文字的輸入。

原文出處:[HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法


This content originally appeared on DEV Community and was authored by Kueiapp


Print Share Comment Cite Upload Translate Updates
APA

Kueiapp | Sciencx (2025-07-09T02:24:07+00:00) [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法. Retrieved from https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/

MLA
" » [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法." Kueiapp | Sciencx - Wednesday July 9, 2025, https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/
HARVARD
Kueiapp | Sciencx Wednesday July 9, 2025 » [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法., viewed ,<https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/>
VANCOUVER
Kueiapp | Sciencx - » [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/
CHICAGO
" » [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法." Kueiapp | Sciencx - Accessed . https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/
IEEE
" » [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法." Kueiapp | Sciencx [Online]. Available: https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/. [Accessed: ]
rf:citation
» [HTML5] iOS Android 只顯示數字鍵盤的 input 輸入元件寫法 | Kueiapp | Sciencx | https://www.scien.cx/2025/07/09/html5-ios-android-%e5%8f%aa%e9%a1%af%e7%a4%ba%e6%95%b8%e5%ad%97%e9%8d%b5%e7%9b%a4%e7%9a%84-input-%e8%bc%b8%e5%85%a5%e5%85%83%e4%bb%b6%e5%af%ab%e6%b3%95/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.