(vue)手機號,驗證碼,身份證,姓名輸入正則校驗

?<input?class="phoneNumTF"??@input="phoneNmVerification"?:value="phoneNm"?type="text"?placeholder="請輸入手機號"?maxlength="11">

?<input?class="codeNumTF"??@input="msgCodeNmVerification"?:value="msgCode"?type="text"?placeholder="請輸入驗證碼"?maxlength="6">

?<input?class="infoContent"?type="text"?@input="idNumberVerification"?:value="idNumber"?placeholder="請輸入您的有效身份證號碼"?maxlength="18">

<input?class="infoContent"?type="text"?@input="nameVerification"?:value="name"?placeholder="請輸入您的真實姓名"?maxlength="15">

methods:{

????????//手機號輸入校驗(只允許輸入數(shù)字)

????????phoneNmVerification(e){

????????????e.target.value=e.target.value.replace(/([^0-9])+/g,?'');

????????????this.phoneNm?=?e.target.value;

????????},

????????//驗證碼輸入校驗(只允許輸入數(shù)字)

????????msgCodeNmVerification(e){

????????????e.target.value=e.target.value.replace(/([^0-9])+/g,?'');

????????????this.msgCode?=?e.target.value;

????????},

?//身份證輸入校驗(只允許輸入數(shù)字和Xx)

????idNumberVerification(e){

??????e.target.value=e.target.value.replace(/([^0-9Xx])+/g,?'');

??????this.idNumber?=?e.target.value;

????},

????//姓名校驗(只允許輸入漢字和英文)

????nameVerification(e){

??????e.target.value=e.target.value.replace(/[^\u4e00-\u9fa5A-Za-z]/,?'');

??????this.name?=?e.target.value;

????},

}

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些閱讀 2,136評論 0 2
  • pyspark.sql模塊 模塊上下文 Spark SQL和DataFrames的重要類: pyspark.sql...
    mpro閱讀 9,911評論 0 13
  • 100個常用的javascript函數(shù) 1、原生JavaScript實現(xiàn)字符串長度截取 復制代碼代碼如下: fun...
    老頭子_d0ec閱讀 409評論 0 0
  • 正則表達式全部符號解釋(轉) 常用正則表達式大全 (轉) 不錯的正則博客 正則的方法 var reg = /[1-...
    me__me11閱讀 1,121評論 0 0
  • 寫在前面的話 代碼中的# > 表示的是輸出結果 輸入 使用input()函數(shù) 用法 注意input函數(shù)輸出的均是字...
    FlyingLittlePG閱讀 3,208評論 0 9

友情鏈接更多精彩內(nèi)容