Smi*_*0ff 6 javascript email reactjs
当我试图改变的状态input[type="email"]上onChange使用事件this.setState({email: e.target.value}),我得到这一堆控制台警告(Chrome浏览器)的:
DOMPropertyOperations.js:143 The specified value "s" is not a valid email address.
DOMPropertyOperations.js:143 The specified value "so" is not a valid email address.
DOMPropertyOperations.js:143 The specified value "som" is not a valid email address.
DOMPropertyOperations.js:143 The specified value "some" is not a valid email address.
Run Code Online (Sandbox Code Playgroud)
当您更改时会发生这种奇怪的行为state,如果您传递数据,则props所有工作都很棒.
有任何想法吗?
PS我添加noValidate到表单中.
小智 0
有很好的文档介绍了您可以对电子邮件输入进行哪些验证,请阅读此文档并调整您的表单:
还通过正确的 REGEX 进行验证,并决定是否需要实时验证(按键、按键)或仅在您失去对该输入的关注时进行验证。希望它可以帮助您更好地理解并帮助您解决问题。