gpt4 book ai didi

javascript - 输入类型的电子邮件在控制台中抛出警告。 react

转载 作者:数据小太阳 更新时间:2023-10-29 05:37:48 25 4
gpt4 key购买 nike

当我尝试使用 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.

当您更改 state 时会发生这种奇怪的行为,如果您传递数据并抛出 props 一切正常。

有什么想法吗?

附言我在表单中添加了 noValidate

最佳答案

关于您可以对电子邮件输入进行哪些验证,有很好的文档,请阅读并调整您的表单:

Data form validation - Web developer guides | MDN

还通过正确的 REGEX 进行验证,并决定是否需要实时验证(keyup、keypress)或仅在您失去对该输入的关注时进行验证。希望它能帮助您更好地理解并帮助您解决问题。

关于javascript - 输入类型的电子邮件在控制台中抛出警告。 react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39448098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com