react ant design 表单验证

金额

<Form.Item
   name="commission"
  label="佣金"
  rules={[
    {
      pattern: /((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/,
      message: '请正确填写佣金'
    }
	]}
	>
	  <Input placeholder="佣金" />
</Form.Item>

电子邮箱

<Form.Item
              name="co_email"
              label="企业邮箱"
              rules={[
                {
                  pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
                  message: '邮箱格式不正确'
                },
                {
                  max: 50, 
                  message: '邮箱不得超过50字符',
                },
              ]}
            >
              <Input placeholder="企业邮箱" />

后面更新

猜你喜欢

转载自blog.csdn.net/junjiahuang/article/details/108072658