我是Java和Regex的新手。在java中使用正則表達式的電話號碼驗證
我必須做簡單的電話號碼驗證。
<input type="tel" maxlength="10">
此處用戶不能輸入超過10個字符。但我需要,如果用戶嘗試輸入字符串值不應該允許。只有數字應該允許,數字之間也不應有空格。請幫助我如何才能實現與reqex。
我是Java和Regex的新手。在java中使用正則表達式的電話號碼驗證
我必須做簡單的電話號碼驗證。
<input type="tel" maxlength="10">
此處用戶不能輸入超過10個字符。但我需要,如果用戶嘗試輸入字符串值不應該允許。只有數字應該允許,數字之間也不應有空格。請幫助我如何才能實現與reqex。
您可以使用
<input onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57" type="number" maxlength="10" />
onkeypress="return (event.charCode == 8 || event.charCode == 0) ? null : event.charCode >= 48 && event.charCode <= 57"
將處理數字輸入maxlength="10"
- 將設置最大符號長度。試試這個
<input type="number" onKeyDown="if(this.value.length==10) return false;" />
''。還是你想禁止從鍵盤輸入非數字? –
是的,我想禁止從鍵盤輸入非數字。 – Ravikanth
Try < = 48 && event.charCode <= 57」type =「number」maxlength =「 10「/>' - 不知道你需要什麼類型,試着用'type =」number「'和'type =」tel「' –