diff --git a/components/form/demo/validate-basic.md b/components/form/demo/validate-basic.md index 339cff3e0a..24a21286cf 100644 --- a/components/form/demo/validate-basic.md +++ b/components/form/demo/validate-basic.md @@ -78,94 +78,92 @@ class BasicDemo extends React.Component { render() { const { getFieldProps, getFieldError, isFieldValidating } = this.props.form; - + const nameProps = getFieldProps('name', { + rules: [ + { required: true, min: 5, message: '用户名至少为 5 个字符' }, + { validator: this.userExists }, + ], + }); + const emailProps = getFieldProps('email', { + validate: [{ + rules: [ + { required: true }, + ], + trigger: 'onBlur', + }, { + rules: [ + { type: 'email', message: '请输入正确的邮箱地址' }, + ], + trigger: ['onBlur', 'onChange'], + }] + }); + const passwdProps = getFieldProps('passwd', { + rules: [ + { required: true, whitespace: true, message: '请填写密码' }, + { validator: this.checkPass.bind(this) }, + ], + }); + const rePasswdProps = getFieldProps('rePasswd', { + rules: [{ + required: true, + whitespace: true, + message: '请再次输入密码', + }, { + validator: this.checkPass2.bind(this), + }], + }); + const textareaProps = getFieldProps('textarea', { + rules: [ + { required: true, message: '真的不打算写点什么吗?' }, + ], + }); + const formItemLayout = { + labelCol: { span: 7 }, + wrapperCol: { span: 12 }, + }; return (
); diff --git a/components/form/demo/validate-customized.md b/components/form/demo/validate-customized.md index 9f5e3e23e9..d93b7b6cf2 100644 --- a/components/form/demo/validate-customized.md +++ b/components/form/demo/validate-customized.md @@ -143,6 +143,10 @@ let Demo = React.createClass({ validator: this.checkPass2, }], }); + const formItemLayout = { + labelCol: { span: 6 }, + wrapperCol: { span: 18 }, + }; return (