如何删除HTML表单中的提交按钮的默认焦点? [英] how to remove the default focus on submit button in HTML form?

查看:573
本文介绍了如何删除HTML表单中的提交按钮的默认焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有一个HTML表单。当我在表单中的某个文本字段中输入一些值并按Enter键时,表单会立即提交。我认为这是由于默认焦点是提交按钮而发生的。但我尝试使用blur()函数删除该焦点,它无法正常工作。我正在使用Chrome。
有没有办法避免这种情况?
欢迎所有建议。提前谢谢。

I have a HTML form on my page. When i am putting some value in one of the text fields in form and press 'Enter key' the form gets submitted instantly. I think this is happening due to default focus is on submit button. But i try to remove that focus using blur() function, it is not working. I am using Chrome. Is there any way to avoid this scenario? All suggestions are welcome. thanks in advance.

推荐答案

没有。重点仍放在文本字段上。按Enter键应该提交表单(并完全绕过提交按钮)。

No. The focus is still on the text field. Pressing enter there is supposed to submit the form (and bypasses the submit button entirely).

您可以抑制使用JavaScript的行为,但由于这是浏览器的正常行为,我不建议这样做。

You can suppress the behavior using JavaScript, but since it is normal behavior for the browser, I wouldn't recommend doing so.

这篇关于如何删除HTML表单中的提交按钮的默认焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆