Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
客户端有一个使用 AJAX 回调提交的联系表单。完成 AJAX 请求后,表单字段将被清除。
这就是问题的表现:清空的表单字段立即被浏览器标记为错误。
有没有办法使用 JavaScript 消除验证错误?
Don't clear individual values, just use the reset() function on the form element. This clears the form to its original (empty) state and no errors appear.
reset()