【发布时间】:2017-05-17 15:20:13
【问题描述】:
我在自定义表单上显示的错误时遇到问题。这是有问题的代码:
<html>
<body>
<form action="/done.html">
<input type="text" id="query" name="query"
required
oninvalid="this.setCustomValidity('What ?')">
<input type="submit">
</form>
</body>
</html>
如果我在输入中输入一些内容,则表单会毫无问题地提交。但是如果我只是按提交,那么即使输入已满也不可能再次提交!
我必须添加onkeypress="this.setCustomValidity('')"。
为什么setCustomValidity 一段时间后没有自动清理?有没有其他没有大量 js 的解决方案?
【问题讨论】:
标签: javascript html css forms