正則表達式校驗
一、校驗手機號
//正則檢測手機號 PRivate _checkPhone(phone: string): boolean { if (!(/^1(3|4|5|7|8)/d{9}$/.test(phone))) { return false; } return true; }二、input只輸入數字,小數點
//js判斷string= string.replace(/[^/d/.]/g, '');//html判斷,有時候要加雙反斜杠“//”<input type="text" class="input-div budget" must="false" placeholder="輸入預算金額" maxlength=10 onkeyup="this.value=this.value.replace(/[^//d//.]/g,'')"/>三、只輸入數字、字母和漢字
//只輸入數字、字母和漢字value = value.replace(/[^(a-zA-Z0-9/u4e00-/u9fa5)]/, '');
新聞熱點
疑難解答