บทนำ
แอตทริบิวต์ autocomplete ควบคุมการเติมอัตโนมัติของเบราว์เซอร์ ตั้งค่าที่ <form> หรือ <input> ได้
ค่าที่เป็นไปได้
| ค่า | คำอธิบาย |
|---|---|
on (default) | เบราว์เซอร์เติมอัตโนมัติจากประวัติ |
off | ปิดการเติมอัตโนมัติ ผู้ใช้ต้องพิมพ์เอง |
name | ชื่อ-นามสกุล |
email | อีเมล |
username | ชื่อผู้ใช้ |
current-password | รหัสผ่านปัจจุบัน |
new-password | รหัสผ่านใหม่ (Generator) |
address-line1 ... | ที่อยู่ (รายละเอียด) |
cc-number | หมายเลขบัตรเครดิต |
off | ปิด autocomplete สำหรับฟิลด์นี้ |
ตัวอย่างปิด Autocomplete ทั้งฟอร์ม
<!DOCTYPE html>
<html>
<head>
<title>HTML Autocomplete Off</title>
</head>
<body>
<form action="" method="get" autocomplete="off">
รายละเอียด:<br><br>
ชื่อนักเรียน<br>
<input type="text" name="sname"><br>
สัปดาห์ฝึกอบรม<br>
<input type="week" name="week"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
หมายเหตุสำคัญ
- เบราว์เซอร์สมัยใหม่อาจ ละเว้น autocomplete="off" สำหรับฟิลด์ Login/Password เพื่อความปลอดภัย
- ใช้
autocomplete="new-password"สำหรับฟิลด์รหัสผ่านใหม่ แทน off - ใช้
autocomplete="one-time-code"สำหรับ OTP