You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.8 KiB
116 lines
2.8 KiB
10 years ago
|
# 校验提示
|
||
10 years ago
|
|
||
9 years ago
|
- order: 6
|
||
10 years ago
|
|
||
9 years ago
|
我们为表单控件定义了三种校验状态,为 `<FormItem>` 定义 `validateStatus` 属性即可。
|
||
10 years ago
|
|
||
9 years ago
|
validateStatus: ['success', 'warning', 'error', 'validating']。
|
||
10 years ago
|
|
||
9 years ago
|
另外为输入框添加反馈图标,设置 `<FormItem>` 的 `hasFeedback` 属性值为 `true` 即可。
|
||
10 years ago
|
|
||
9 years ago
|
**注意**: 反馈图标只对 `<Input />` 有效。
|
||
10 years ago
|
|
||
|
---
|
||
|
|
||
9 years ago
|
````jsx
|
||
9 years ago
|
import { Form, Input, DatePicker, Col } from 'antd';
|
||
9 years ago
|
const FormItem = Form.Item;
|
||
10 years ago
|
|
||
9 years ago
|
ReactDOM.render(
|
||
9 years ago
|
<Form horizontal>
|
||
|
<FormItem
|
||
|
label="失败校验:"
|
||
|
labelCol={{span: 5}}
|
||
|
wrapperCol={{span: 12}}
|
||
|
validateStatus="error"
|
||
|
help="请输入数字和字母组合">
|
||
9 years ago
|
<Input defaultValue="无效选择" id="error" />
|
||
9 years ago
|
</FormItem>
|
||
10 years ago
|
|
||
9 years ago
|
<FormItem
|
||
|
label="警告校验:"
|
||
|
labelCol={{span: 5}}
|
||
|
wrapperCol={{span: 12}}
|
||
|
validateStatus="warning">
|
||
9 years ago
|
<Input defaultValue="前方高能预警" id="warning" />
|
||
9 years ago
|
</FormItem>
|
||
9 years ago
|
|
||
9 years ago
|
<FormItem
|
||
|
label="校验中:"
|
||
|
labelCol={{span: 5}}
|
||
|
wrapperCol={{span: 12}}
|
||
9 years ago
|
hasFeedback
|
||
9 years ago
|
validateStatus="validating"
|
||
|
help="信息审核中...">
|
||
9 years ago
|
<Input defaultValue="我是被校验的内容" id="validating" />
|
||
9 years ago
|
</FormItem>
|
||
10 years ago
|
|
||
9 years ago
|
<FormItem
|
||
|
label="成功校验:"
|
||
|
labelCol={{span: 5}}
|
||
|
wrapperCol={{span: 12}}
|
||
9 years ago
|
hasFeedback
|
||
9 years ago
|
validateStatus="success">
|
||
9 years ago
|
<Input defaultValue="我是正文" id="success" />
|
||
9 years ago
|
</FormItem>
|
||
9 years ago
|
|
||
9 years ago
|
<FormItem
|
||
|
label="警告校验:"
|
||
|
labelCol={{span: 5}}
|
||
|
wrapperCol={{span: 12}}
|
||
9 years ago
|
hasFeedback
|
||
9 years ago
|
validateStatus="warning">
|
||
9 years ago
|
<Input defaultValue="前方高能预警" id="warning" />
|
||
9 years ago
|
</FormItem>
|
||
10 years ago
|
|
||
9 years ago
|
<FormItem
|
||
|
label="失败校验:"
|
||
|
labelCol={{span: 5}}
|
||
|
wrapperCol={{span: 12}}
|
||
9 years ago
|
hasFeedback
|
||
9 years ago
|
validateStatus="error"
|
||
|
help="请输入数字和字母组合">
|
||
9 years ago
|
<Input defaultValue="无效选择" id="error" />
|
||
9 years ago
|
</FormItem>
|
||
9 years ago
|
|
||
9 years ago
|
<FormItem
|
||
9 years ago
|
label="Datepicker:"
|
||
9 years ago
|
labelCol={{span: 5}}
|
||
9 years ago
|
help>
|
||
9 years ago
|
<Col span="6">
|
||
9 years ago
|
<FormItem validateStatus="error" help="请选择正确日期">
|
||
|
<DatePicker />
|
||
|
</FormItem>
|
||
9 years ago
|
</Col>
|
||
|
<Col span="1">
|
||
|
<p className="ant-form-split">-</p>
|
||
|
</Col>
|
||
|
<Col span="6">
|
||
9 years ago
|
<FormItem>
|
||
|
<DatePicker />
|
||
|
</FormItem>
|
||
9 years ago
|
</Col>
|
||
|
</FormItem>
|
||
9 years ago
|
|
||
|
<FormItem
|
||
|
label="Datepicker:"
|
||
9 years ago
|
labelCol={{span: 5}}
|
||
|
validateStatus="error"
|
||
|
help>
|
||
9 years ago
|
<Col span="6">
|
||
9 years ago
|
<DatePicker />
|
||
9 years ago
|
</Col>
|
||
|
<Col span="1">
|
||
|
<p className="ant-form-split">-</p>
|
||
|
</Col>
|
||
|
<Col span="6">
|
||
9 years ago
|
<DatePicker />
|
||
|
</Col>
|
||
|
<Col span="19" offset="5">
|
||
|
<p className="ant-form-explain">请选择正确日期</p>
|
||
9 years ago
|
</Col>
|
||
|
</FormItem>
|
||
9 years ago
|
</Form>
|
||
9 years ago
|
, mountNode);
|
||
10 years ago
|
````
|