【问题标题】:input oninvalid custom message still maintains invalid after selecting the boxinput oninvalid 自定义消息选中框后仍然保持无效
【发布时间】:2017-10-06 15:48:41
【问题描述】:

正在处理获取输入(复选框)以在自定义消息无效(未选中)时显示自定义消息,但在此之后,如果用户选中该框,则消息仍会显示并被视为无效。我认为这与 oninvalid 但不确定。

输入代码

<input style="width:15px; height:15px; cursor: pointer;" class="form-check-input" type="checkbox" onclick="setCustomValidity('')" oninvalid="this.setCustomValidity('Please review the legal agreement and check this box to proceed')" required>

我首先收到错误消息,然后选中复选框后得到的图片

`

【问题讨论】:

  • setCustomValidity 代码在哪里?
  • @GibralterTop setCustomValidity 方法只是将消息分配为无效,documentation

标签: html angularjs twitter-bootstrap-3


【解决方案1】:

这对我有用

            <input style="width:15px; height:15px; cursor: pointer;" name="legal"
        class="form-check-input" type="checkbox" required id="legal"
        onchange="this.setCustomValidity(validity.valueMissing ? 'Please review the legal agreement and check this box to proceed' : '');">

在控制器上

    document.getElementById("legal").setCustomValidity("Please review the legal agreement and check this box to proceed");

【讨论】:

    猜你喜欢
    • 2014-02-17
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-12
    • 2017-05-08
    相关资源
    最近更新 更多