Validation error: Attribute onfocusout not allowed on element input at this point

Validation error: Attribute onfocusout not allowed on element input at this point

我想在输入元素上使用“onfocusout”。不幸的是,我的验证器 return 出现以下错误消息:“此时元素输入不允许属性 onfocusout。”

html 代码如下所示:

<div  class="form-group">
  <label  for="dbHost"  class="control-label col-sm-4">DB-Server</label>
  <div  class="col-sm-10">
    <input  type="text" class="form-control" id="dbHost" name="dbHost" onfocusout="validateForm();" value="db">
  </div>
<div>

有什么想法吗?

Note: The onfocusout event may not work as expected in Chrome, Safari and Opera 15+ using the JavaScript HTML DOM syntax. However, it should work as an HTML attribute and by using the addEventListener() method (See syntax examples below).

In JavaScript, using the addEventListener() method:

object.addEventListener("focusout", myScript);

Source