react-component / form

React High Order Form Component(web & react-native)
http://react-component.github.io/form/
MIT License
1.81k stars 296 forks source link

When I'm typing, I don't want pattern real-time listening for judgment. #207

Closed walk-liuyan closed 6 years ago

walk-liuyan commented 6 years ago

Current solution

  <FormItem
          {...formItemLayout}
          label="密码"
          validateStatus={passwordError ? 'error' : ''}
          help={passwordError || ''}
        >
          {getFieldDecorator('password', {
            rules: [
              { required: true, message: '请输入密码' },
              { min: 8, message: '密码长度不小于 8 位' },
              { validator: this.validateToNextPassword },
            ],
          })(
            <Input type="password" placeholder="请输入密码" onBlur={this.handleConfirmBlur} autoComplete="off" />,
          )}
        </FormItem>
  validateToNextPassword = (rule, value, callback) => {
    clearTimeout(this.state.queue);
    this.setState({
      queue: setTimeout(() => {
        const form = this.props.form;
        if (value && this.state.confirmDirty) {
          form.validateFields(['confirmPassword'], { force: true });
        }
        callback();
      }, 900),
    });
  }

Is there a method for deplay in input ?(delay monitoring)

zombieJ commented 6 years ago

You can set validateTrigger to onBlur : )