日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

html5 提交from,刨根问底:HTML中form的隐式提交

發(fā)布時間:2025/3/19 HTML 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html5 提交from,刨根问底:HTML中form的隐式提交 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

有時在HTML頁面form的input里按了回車鍵會提交該表單,并且form的submit按鈕的click事件也會被觸發(fā).這是什么原理呢?是因為form的隱式提交(Implicit submission)機制

在https://www.w3.org/TR/html52/sec-forms.html#implicit-submission中是這么解釋的

A form element’s default button is the first Submit Button in tree order whose form owner is that form element.

form的第一個submit按鈕作為default button

If the user agent supports letting the user submit a form implicitly (for example, on some platforms hitting the "enter" key while a text field is focused implicitly submits the form), then doing so for a form whose default button has a defined activation behavior must cause the user agent to run synthetic click activation steps on that default button.

瀏覽器隱式提交時要觸發(fā)default button的click事件.在某些平臺上,text field獲得焦點時,按回車鍵會觸發(fā)隱式提交

If the form has no Submit Button, then the implicit submission mechanism must do nothing if the form has more than one field that blocks implicit submission, and must submit the form element from the form element itself otherwise.

For the purpose of the previous paragraph, an element is a field that blocks implicit submission of a form element if it is an input element whose form owner is that form element and whose type attribute is in one of the following states: Text, Search, URL, Telephone, E-mail, Password, Local Date and Time, Date, Month, Week, Time, Number

form里有超過一個的input時,必須阻止隱式提交

在早期的HTML規(guī)范中,還有如下描述

When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form.

總結

以上是生活随笔為你收集整理的html5 提交from,刨根问底:HTML中form的隐式提交的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。