_ischinese
(strvalue)
_islicenseplate
(strvalue)
[a-hj-np-z][a-hj-np-z0-9][a-hj-np-z0-9掛學警港澳]$/
;return license_plate_reg.
test
(strvalue)
;}
_istelormobile
(strvalue)
-\d(-\d)?$/
;let mobile_reg =
/^(1(3|4|5|6|7|8|9)\d)$/
;return phone_reg.
test
(strvalue)
|| mobile_reg.
test
(strvalue)
;}
_isposinteger
(strvalue)
_isinteger
(strvalue)
_isnonnegative
(strvalue)
_isemail
(strvalue)
~-]+@[a-za-z0-9](?:[a-za-z0-9-][a-za-z0-9])?(?:\.[a-za-z0-9](?:[a-za-z0-9-][a-za-z0-9])?)*$/
;return reg.
test
(strvalue)
;}
_isnumorletter
(strvalue)
_isnonnegativeint
(strvalue)
_isvaliddate
(strvalue)
-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/
;return reg.
test
(strvalue)
;}
_isareacode
(strvalue)
-?)/
;return reg.
test
(strvalue)
;}
_isioq
(strvalue)
_ispostcode
(strvalue)$/;
return reg.
test
(strvalue)
;}
_checkidentifycard
(idcard, text)
vary
,jym
;vars,
m;var idcard_array =
newarray()
; idcard_array = idcard.
split(""
);var ereg ="";
// 身份號碼位數及格式檢驗
switch
(idcard.length)
[0-9]((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]$/
;// 測試出生日期的合法性
}else
[0-9]((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]$/
;// 測試出生日期的合法性}if
(!ereg.
test
(idcard)
)break
;case18:
// 18位身份號碼檢測
// 出生日期的合法性檢查
// 閏年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
// 平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))if(
parseint
(idcard.
substr(6
,4))
%4==0
||(parseint
(idcard.
substr(6
,4))
%100==0
&&parseint
(idcard
.substr(6
,4))
%4==0
))(19[0-9]|20[0-1][0-9])((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9][0-9x]$/
;// 閏年出生日期的合法性正規表示式
}else
(19[0-9]|20[0-1][0-9])((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9][0-9x]$/
;// 平年出生日期的合法性正規表示式}if
(ereg.
test
(idcard))}
else
break
;default
: errmsg = errors[1]
;break;}
if(errmsg ==="")
}}return errmsg;
}
_decimalpoint
(strvalue)
|[1-9][0-9]*\.\d)))$/
;return reg.
test
(strvalue)
;}
常見的正則校驗規則
手機號的校驗規則 13 0 9 14 5,7 15 0 3,5 9 17 0,3,5 8 18 0 9 166 198 199 147 d vue用法例項 vue.prototype.ismobile rule,value,callback if mobilereg.test value else ...
常用的一些校驗
js 校驗是否全由數字組成 function isdigit s if patrn.exec s return false return true 校驗登入名 只能輸入5 20個以字母開頭 可帶數字 的字串 function isregisterusername s a za z0 9 if pat...
eslint 的一些規則
parenthese 圓括號 curly brace 花括號 comma 逗號 semicolon 分號 函式體中沒有花括號引數就不要有圓括號 物件中值必須要用單引號 定義但是沒有被使用,一般是可以被刪除的。有一種情況就是屬性驗證。proptypes沒有被使用,但是需要自己寫屬性驗證,所以就會被用上...