在reactjs中的formitem中添加验证

时间:2018-10-11 11:48:45

标签: reactjs antd

在我的reactjs代码中,我想添加密码和电子邮件的验证。怎么样?

            <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 :(得分:0)

通过简单的电子邮件和密码验证签出此Codepen: https://codepen.io/lukejsimonetti/pen/XxgbgP?editors=0010

您已经关闭。您似乎在规则中缺少<?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'stripe/*', 'http://example.com/foo/bar', 'http://example.com/foo/*', ]; } 。像这样:

type

来自Ant Design文档,此处: https://ant.design/components/form/#components-form-demo-register