Redux Forms中有没有一种方法可以让代码验证表单?
答
是的,如果你使用jQuery,您可以创建使用的表单输入CSS选择像下面
var __inputListener__ = $("input[name=firstName]).click(function (e) {checkString(e.target.value);});
function checkString(string) {
//Run string validation here
if (true)
return true;
else
return false;
}
注意事件侦听器,我不知道这是e.target.value
将返回值,你可能需要console.log(e)
才能获得e
的数组,并查看它的位置。你只要重复这一过程,你要多少投入检查等
编辑: 忘了提,你的意思是SET事件侦听器后你想它来听元素已创建。
答
试试下面的代码:
componentDidMount() {
this.props.touch('username', 'email', 'age') // pass names of input fields
}
马特,我的道歉,但这个问题是关于终极版形式... –