輸入立即校驗格式:
<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>