H5新增事件之oninput和oninvalid

2021-09-19 06:10:56 字數 368 閱讀 7237

事件介紹:

oninput 使用者輸入內容時觸發,可用於移動端輸入字數統計

oninvalid 驗證不通過時觸發

舉例:/*oninput可以監聽使用者的每一次輸入*/

document.getelementbyid("name").oninput=function()

/*監聽鍵盤彈起,每乙個鍵盤彈出觸發一次*/

document.getelementbyid("name").onkeyup=function()

/*當指定表單元素驗證不通過時觸發*/

document.getelementbyid("phone").oninvalid=function()

H5 新增表單屬性和事件

doctype html html lang en head meta charset utf 8 title title title head body form action 使用者名稱 input type text name username br br 密碼 input type pass...

h5 新增屬性

預設提示內容 placeholder 多輸入,多提交 multiple 支援乙個域中多輸入,逗號隔開,一般配合郵箱和url型別使用 自動獲取焦點,頁面載入,自動獲取焦點游標 autofocus 防止空提交 required 允許輸入的最小字元數和最大字元數 minlength 允許輸入的最小字元長度...

H5新增屬性

doctype html en utf 8 viewport content width device width,initial scale 1.0 document title cursor pointer 出現小手 button 屬性選擇器使用方法 相當於交集選擇器,即表示既有button屬性...