ant desgin react表单验证

地址:https://blog.csdn.net/hope93/article/details/84302341

{getFieldDecorator(names[${key}], {
validateTrigger: [‘onChange’, ‘onBlur’],
rules: [{
required: true, message: ‘请输入’,
}, { validator: this.validateIsNull }],
//验证是否存在空格
validateIsNull = (rule, value, callback) => {
if (/\s/.test(value)) {
callback(‘输入存在空格,请检查’);
return;
}
callback();
}

猜你喜欢

转载自blog.csdn.net/k_x_sh/article/details/88949191