antd Fromフォームについて検証します.
1916 ワード
1.数字のみ入力できます.
-
{getFieldDecorator("code", {
initialValue: code,
rules: [
{
required: true,
message: " code"
},
{
required: false,
pattern: new RegExp(/^[1-9]\d*$/, "g"),
message: ' code'
}
],
// ,
getValueFromEvent: (event) => {
return event.target.value.replace(/\D/g,'')
},
})(
)}
2.携帯番号判定検証 -
{getFieldDecorator("phone", {
initialValue: phone,
rules: [
{
required: true,
message: " "
},
{
required: false,
pattern: new RegExp(/^1(3|4|5|6|7|8|9)\d{9}$/, "g"),
message: ' '
}
],
getValueFromEvent: (event) => {
return event.target.value.replace(/\D/g,'')
},
})(
)}
3.身分証明書の検証 /**
* 1-9]\d{5}: , 0 ;
* (18|19|20): 18 19 20, ;
* \d{2}: 2 , ;
* ((0[1-9])|(10|11|12)): ,01-12 ;
* (([0-2][1-9])|10|20|30|31): ,01-31 ,
* \d{3}[0-9Xx]: +
*/
-
{getFieldDecorator("IDCard", {
initialValue: IDCard,
rules: [
{
required: true,
message: " "
},
{
required: false,
pattern: new RegExp(/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, "g"),
message: ' '
}
],
})(
)}
!!~更新し続ける