【发布时间】:2019-03-13 17:53:36
【问题描述】:
我有带有复选框隐私政策的登录表单(必需),如果未选中,我希望显示自定义 html5 验证消息并单击表单提交。我使用了内联javascript:
<input name="privacypolicy" title="Please agree to our privacy policy" id="privacypolicy" required="" oninput="this.setCustomValidity('')" oninvalid="this.setCustomValidity('Please agree to our privacy policy')" type="checkbox" value="agree">
这适用于 chrome 和 firefox。但不适用于 IE(11 或边缘)。 设想: 1. 如果一切正确并提交,它就可以工作。 2. 如果没有勾选然后提交,会弹出验证信息。但是即使检查并提交后,它仍然显示错误消息并且表单根本没有提交。
请帮忙!
【问题讨论】:
标签: javascript html validation internet-explorer