antd表单输⼊⽴即校验和点击确认按钮校验输⼊⽴即校验格式:
<FormItem label='数据值' required={false}>
{getFieldDecorator('accountValue', {
validateTrigger: ['onChange', 'onBlur'],
initialValue: undefined,
validateFirst: true,
rules: [
{
pattern: type === '1020003' && REG_IMSI,
message: '请输⼊正确的IMSI',
},
{
pattern: type === '1020004' && REG_MOBILE,
message: '请输⼊正确的⼿机号',
},
{
pattern: type === '1020002' && REG_MAC,
message: '请输⼊正确的MAC',
},
{
微博加载失败pattern: type === '1030036' && REG_WX,
message: '请输⼊正确的',
},
{
pattern: type === '1030001' && REG_QQ,
message: '请输⼊正确的QQ',
},
{
pattern: type === '1021901' && REG_IMEI,
message: '请输⼊正确的IMEI',
},
{
pattern: type === '1330000' && REG_WEIBO,
message: '请输⼊正确的微博',
},
],
})(<Input
autoComplete="off"
addonAfter={
getFieldDecorator('accountType', {
initialValue: type || undefined,
onChange: this.accountTypeChange.bind(this),
})(
<Select style={{width: 80}}>
<Option value="1020003">IMSI</Option>
<Option value="1020004">⼿机号</Option>
<Option value="1021901">IMEI</Option>
<Option value="1020002">MAC</Option>
<Option value="1030036"></Option>
<Option value="1030001">QQ</Option>
<Option value="1330000">微博</Option>
</Select>
)}
style={{ width: '100%', marginRight: 8 }}
placeholder="请输⼊数据值"
allowClear
/>)}
</FormItem>
点击确认按钮进⾏格式校验:
<FormItem label='数据值' required={false}>
{getFieldDecorator('accountValue', {
validateTrigger: ['onSubmit'],
initialValue: undefined,
validateFirst: false,
rules: [
{
pattern: type === '1020003' && REG_IMSI,
message: '请输⼊正确的IMSI',
},
{
pattern: type === '1020004' && REG_MOBILE,
message: '请输⼊正确的⼿机号',
},
{
pattern: type === '1020002' && REG_MAC,
message: '请输⼊正确的MAC',
},
{
pattern: type === '1030036' && REG_WX,
message: '请输⼊正确的',
},
{
pattern: type === '1030001' && REG_QQ,
message: '请输⼊正确的QQ',
},
{
pattern: type === '1021901' && REG_IMEI,
message: '请输⼊正确的IMEI',
},
{
pattern: type === '1330000' && REG_WEIBO, message: '请输⼊正确的微博',
},
],
})(<Input
autoComplete="off"
addonAfter={
getFieldDecorator('accountType', {
initialValue: type || undefined,
onChange: this.accountTypeChange.bind(this), })(
<Select style={{width: 80}}>
<Option value="1020003">IMSI</Option>
<Option value="1020004">⼿机号</Option> <Option value="1021901">IMEI</Option>
<Option value="1020002">MAC</Option>
<Option value="1030036"></Option>
<Option value="1030001">QQ</Option>
<Option value="1330000">微博</Option>
</Select>
)}
style={{ width: '100%', marginRight: 8 }}
placeholder="请输⼊数据值"
allowClear
/>)}
</FormItem>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论