如何停用 HTML 輸入域的自動補全?


要停用輸入域的自動補全,程式碼如下 −

示例

 即時演示

<!DOCTYPE html>
<html>
<head>
<style>
   input{
      font-size: 18px;
      padding: 10px;
      margin: 10px;
      border:1px solid grey;
   }
</style>
</head>
<body>
<h1>Autocomplete on/off Example</h1>
<form>
First name: <input type="text" name="firstName" autocomplete="off"><br>
Last name: <input type="text" name="lastName" autocomplete="on"><br>
<input type="submit">
</form>
<h2>Type in the above fields and refresh page to see autocomplete at work</h2>
</body>
</html>

輸出

以上程式碼將產生以下輸出 −

在提交表單一次後在以上欄位中輸入一些內容 −

更新於: 06-May-2020

231 次瀏覽

開啟您的 職業生涯

完成課程,獲得認證

立即開始
廣告
© . All rights reserved.