Добавить подтверждение в formitem в Reactionjs - PullRequest
0 голосов
/ 11 октября 2018

В своем коде реагирования я хочу добавить подтверждение для пароля и электронной почты.Как?

            <Col span={12}>
                <FormItem>
                    {getFieldDecorator('Password', {
                        initialValue: "",
                        rules: [{
                            required: true, message: 'Please Input your Password!',
                        }],
                    })(
                        <Input placeholder="Password" />
                    )}
                </FormItem>
            </Col>

            <Col span={12}>
                <FormItem>
                    {getFieldDecorator('Email', {
                        initialValue: "",
                        rules: [{
                            required: true, message: 'Please Input your Email!',
                        }],
                    })(
                        <Input placeholder="Email" />
                    )}
                </FormItem>
            </Col>

Также я хочу скрыть пароль с помощью пуль или чего-либо еще

1 Ответ

0 голосов
/ 11 октября 2018

Оформить заказ на этот код с простой проверкой электронной почты и пароля: https://codepen.io/lukejsimonetti/pen/XxgbgP?editors=0010

Вы близки.Похоже, вам не хватает type в правилах.Примерно так:

            <FormItem
                {...formItemLayout}
                label="E-mail"
            >
                {getFieldDecorator('email', {
                    rules: [{
                        // declare the type and message here
                        type: 'email', message: 'The input is not valid E-mail!',
                    }, {
                        required: true, message: 'Please input your E-mail!',
                    }],
                })(
                    <Input />
                )}
            </FormItem>
            <FormItem
                {...formItemLayout}
                label="Password"
            >
                {getFieldDecorator('password', {
                    rules: [{
                        required: true, message: 'Please input your password!',
                    }, {

                        // run some custom validator function here on your class
                        validator: this.compareToConfirmPassword,
                    }],
                })(
                    <Input type="password" />
                )}
            </FormItem>

Взято из документации Ant Design здесь: https://ant.design/components/form/#components-form-demo-register

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...