简体   繁体   English

onblur 事件仅在 Firefox 中的备用输入字段上触发

[英]onblur event fires only on alternate input fields in Firefox

After each form input element, I need to do a verification using the same script.在每个表单输入元素之后,我需要使用相同的脚本进行验证。
I used onblur=myFunction("name") (where nam e is the name= attribute for the form field) in each form element so when the user presses <tab> the cursor advances to the next entry field.我用onblur=myFunction("name")其中, nam e是name=属性表单域)中的每个表格元件,以便当用户按下<tab>光标前进到下一输入字段。

The problem is that Firefox (Linux 93.0 - 64 bit) fires the onblur event ONLY on odd-numbered form input fields.问题是 Firefox(Linux 93.0 - 64 位)仅在奇数表单输入字段上触发onblur事件。 The even numbered ones lose focus without executing the event handler.偶数编号不执行事件处理程序就失去焦点。
Sometimes, but not always, I can force the event to fire by clicking on a different form input field, or rotating out and back into the form.有时,但并非总是如此,我可以通过单击不同的表单输入字段或旋转出并返回到表单中来强制触发事件。 This is very consistent.这是非常一致的。

Here are two example sequential fields from the real form, ' fname ' fires the event, ' lname ' does not.下面是来自真实表单的两个示例顺序字段,“ fname ”触发事件,“ lname ”不触发。
There is a total of 17 named input fields.共有 17 个命名输入字段。 The style for these fields does not reflect the "unfocused" state after the cursor exits the field either.这些字段的样式也不反映光标退出该字段后的“未聚焦”状态。

<label for="fname" class="shipping">First Name</label>
<input type="text" class="shipping" name="fname" id="fname" maxlength=24 size=20 placeholder="First Name" autofocus onBlur=field_check("fname")>
<label for="lname" class="shipping">Last Name</label>
<input type="text" class="shipping" name="lname" id="lname" maxlength=48 size=30 placeholder="Last Name" required onBlur=field_check("lname")> 

How to fix this issue?如何解决这个问题?

Thank you to those who responded, even though nobody had an answer.感谢那些回答的人,即使没有人回答。 I did a lot of testing and found that the problem is interference between the CSS styles and the inline onBlur, onChange, etc. When these are removed all works as expected although I can no longer determine when a field has been completed.我做了很多测试,发现问题是 CSS 样式和内联 onBlur、onChange 等之间的干扰。当这些被删除时,所有工作都按预期进行,尽管我无法确定某个字段何时完成。 Testing, I found that Firefox (Linux and Windows) will respond to every second event, so alternate lines do not get styled and do not report data entry.测试时,我发现 Firefox(Linux 和 Windows)会每隔一个事件响应一次,因此备用行不会设置样式并且不会报告数据输入。 Chrome on Windows will hang after the third field is entered and the pop up cannot be dismissed without closing the browser.输入第三个字段后,Windows 上的 Chrome 将挂起,并且在不关闭浏览器的情况下无法关闭弹出窗口。 An old version of Internet Explorer (!) worked exactly as expected but I couldn't test either Edge or Safari since I don't have them installed here.旧版本的 Internet Explorer (!) 完全按预期工作,但我无法测试 Edge 或 Safari,因为我没有在此处安装它们。
Overall, there seems to be some disconnect between the documentation and the implementation on mainstream browsers but I have run out of time to try and find it so I'll have to find a "plan B".总体而言,文档和主流浏览器上的实现之间似乎存在一些脱节,但我没有时间尝试找到它,所以我必须找到一个“计划 B”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM