如何在不使用所必需的屬性的情況下驗證 HTML5 輸入


要避免驗證,在 HTML5 中使用 formnovalidate 屬性。在示例中,停用了第 2 個按鈕的驗證 −

示例

<!DOCTYPE html>
<html>
   <head>
      <title>HTML formnovalidate attribute</title>
   </head>
   <body>
      <form action = "new.php" method = "get">
         Rank <input type = "number" name = "rank" required><br>
         <input type = "submit" value = "Submit"><br>
         <input type = "submit" formnovalidate = "formnovalidate" value = "Submit with no validation">
      </form>
   </body>
</html>

更新於:2020 年 6 月 25 日

154 次瀏覽

開啟您的 職業生涯

完成課程後獲得認證

開始
廣告