antdesign的input增加自定义校验规则

rules: [
	{required: true, message: '请输入姓名'},
	{max: 16, message: '姓名过长'},
	{ validator:  (rule, val, callback) => {
	  var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
	  if (pattern.test(val)){
		  callback('不可输入特殊字符');
	  }else {
		 callback();
	  }
		callback();
	  },
	},
],
posted @ 2019-11-28 18:50  经典鸡翅  阅读(5561)  评论(0编辑  收藏  举报