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