1
Phone:<br>
<input type="text" id="phone" name="phone" placeholder="Please enter your phone number">
The input box looks like this to begin with
On click/focus, it looks like this
在鍵入數字值,下劃線應該得到更換或數字應該得到輸入過下劃線
我試過類似
<input type="text" name="theName" placeholder="Please enter your phone number"
onblur="if(this.placeholder!==''){ this.value='Please enter your phone number'; this.style.color='#BBB';}"
onfocus="if(this.placeholder=='Please enter your phone number'){ this.value='___-___-____'; this.style.color='#000';}"
style="color:#BBB;" />
但正如我開始輸入電話號碼,我想讓它變得鍵入了下劃線,而不是像他們現在。
我相信你的問題沒有簡單的答案,你可以使用這裏提到的庫:https://css-tricks.com/input-masking/。 – Javad
輸入掩碼正是我所期待的。不知道這個名字是知道的。謝謝! (我能夠解決它,並將其作爲答覆發佈) – manishk