HTML5验证错误消息

时间:2018-07-02 05:05:47

标签: javascript php html validation html5-validation

如何防止浏览器显示默认的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);

1 个答案:

答案 0 :(得分:1)

如果要禁用HTML5中表单的客户端验证,请向表单元素添加novalidate属性。像这样:

<form method="post" action="/mycation" novalidate>...</form>