Я пытаюсь сделать «поле 2 не совпадает с полем 1» вещь здесь (т.е. «пароли не совпадают).правила getFieldDecorator для сброса пароля? AntD рамки
Там isn't much documentation на доступных правил для antd форм. Они указывают на это . проект here
Ниже моя текущая форма:
const ResetPasswordForm = Form.create()(React.createClass({
getInitialState() {
return {
loading: false
};
},
handleSubmit(e) {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (err) {
failure();
}
if (!err) {
let newPassword = values.newPassword;
let repeatNewPassword = values.repeatNewPassword;
handleResetPassword(newPassword, repeatNewPassword, this.props.token);
}
});
},
render() {
const { getFieldDecorator } = this.props.form;
const newPasswordRules = [
{ required: true, message: 'Please input a new password!' }
];
const repeatNewPassword = [
{ required: true, message: 'Please repeat the new password!' }
];
return (
<Form onSubmit={this.handleSubmit} className="login-form">
<FormItem>
{getFieldDecorator('newPassword', { rules: newPasswordRules })(
<Input addonBefore={<Icon type="lock" />} type="password" placeholder="New password" />
)}
</FormItem>
<FormItem>
{getFieldDecorator('repeatNewPassword', { rules: repeatNewPassword })(
<Input addonBefore={<Icon type="lock" />} type="password" placeholder="Repeat new password" />
)}
</FormItem>
<FormItem>
<Button loading={this.state.loading} type="primary" htmlType="submit" className={css(styles.loginButton)}>
Reset Password
</Button>
</FormItem>
</Form>
);
}
}));
Если кто-то может мне точку в правильном направлении для создания правила, которое проверяет, что первое значение поля совпадает со вторым, что было бы здорово!
Это как-то проплыло мимо меня. Благодарю. – arcom