1. 程式人生 > >移動端密文彈數字鍵盤

移動端密文彈數字鍵盤

當我們開發移動端頁面上的輸入框,需要輸入密文時,一般我們會用如下方式實現:

當type="password"時,輸入框顯示為圓點密文,調起的是英文鍵盤

<input type="password" placeholder="password"/>

 

但有的時候輸入的密文得是純數字格式,這時候產品就要求我們彈出的預設輸入鍵盤為數字鍵盤,這該怎麼實現。

優化方案:當type="number" 或者 type="tel" 時,想要輸入框顯示圓點密文,同時調起數字鍵盤

<input type="tel" placeholder="tel" placeholder
="tel" style="-webkit-text-security:disc;text-security:disc;"/>

為了在移動端實現密碼輸入框且調起的鍵盤為數字鍵盤,可以用-webkit-text-security:disc;text-security:disc;屬性來實現。

語法: 
text-security: circle | disc | none | square; 
-webkit-text-security: circle | disc | none | square;

none 無。
circle 圓圈。
disc 圓形。


square 正方形。