我有一个表单,我在其中禁用提交按钮,直到用户输入所有必填字段。我最初使用 onkeyup
在必填字段上保留一个选项卡,并在填写所有必填字段时启用该按钮。
但我有用户提示他们使用 Google 工具栏上的自动填充按钮填写表单,但提交按钮仍然被禁用。
我通过为每个输入元素调用 onpropertychange
事件解决了 IE 中的这个问题,并且效果很好。
但在 Firefox 中,我找不到点击 Google 自动填充按钮时会触发的事件。
非常感谢帮助。
最佳答案
感谢您的回答。我必须快速响应这个问题,因此我使用“setTimeOut()”函数来检查必填字段并启用提交按钮。
$().ready(function() {
CheckRequiredFields();
timeOutRtn = setTimeout("AutoMonitorMandatoryField()", "3000");
});
function AutoMonitorMandatoryField() {
if ($("#btnSave").attr("disabled")) {
CheckRequiredFields();
timeOutRtn = setTimeout("AutoMonitorMandatoryField()", "3000");
}
}
crescentfresh - 我会查看 DOMAttrModified 事件,看看是否可以让它为我工作。谢谢
关于javascript - 在 Firefox 上使用 Google 自动填充时触发 JavaScript 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1492994/