如何防止浏览器显示默认的HTML5验证错误消息提示框?
document.addEventListener('invalid', (function() {
return function(e) {
//prevent the browser from showing default error bubble / hint
e.preventDefault();
// optionally fire off some custom validation handler
// myValidation();
};
})(), true);
答案 0 :(得分:1)
如果要禁用HTML5中表单的客户端验证,请向表单元素添加novalidate
属性。像这样:
<form method="post" action="/mycation" novalidate>...</form>