實現input輸入框只能輸入數字的效果:
<input type="text" name="" id="phoneNum" value="" class="mui-input" placeholder="請輸入您的11位手機號" oninput='this.value=this.value.replace(/\D/gi,"")' maxlength="11"/>
//當輸入時觸發input事件,然后判斷輸入框中的值,如果不為數字則替換為‘’,maxlength屬性規定input框最多輸入的字符個數為11位;
//適用場景為:例如只能輸入手機號,qq號等情況。