使用 Antd 验证电话号码,type="number" 不起作用

问题描述 投票:0回答:1
reactjs forms validation antd
1个回答
0
投票

为了在 antd 中验证电话号码,您应该使用模式和正则表达式。 例如:

rules: [
      {
        required: true,
        type: "regexp",
        pattern: new RegExp(/\d+/g),
        message: "Wrong format!"
      }
    ]

当然,你应该添加你想要的模式而不是我的例子

© www.soinside.com 2019 - 2024. All rights reserved.