--- order: 12 title: zh-CN: 校验其他组件 en-US: Other Form Controls --- ## zh-CN 以上演示没有出现的表单控件对应的校验演示。 ## en-US Demostration for validataion configuration for form controls which are not show in the above demos. ````jsx import { Select, Button, InputNumber, Form } from 'antd'; const Option = Select.Option; const FormItem = Form.Item; const Demo = Form.create()(React.createClass({ handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (err) { return; } console.log('Received values of form: ', values); }); }, checkPrime(rule, value, callback) { if (value !== 11) { callback(new Error('The prime number between 8 to 12 is 11!')); } else { callback(); } }, render() { const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 7 }, wrapperCol: { span: 12 }, }; return (
); }, })); ReactDOM.render(