Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

Autocomplete Text Input ใน HTML5

แอตทริบิวต์ autocomplete

ควบคุมว่เบราว์เซอร์ควรแสดงคำแนะนำจากประวัติหรือไม่

ค่า Attribute

ค่าคำอธิบาย
on (Default)เบราว์เซอร์แสดงคำแนะนำจากประวัติ
offปิด Autocomplete ผู้ใช้ต้องพิมพ์เอง

ตัวอย่าง

<!DOCTYPE html>
<html>
<head><title>HTML autocomplete</title></head>
<body>
  <form action="" method="get" autocomplete="on">
    <label>ชื่อ: <input type="text" name="sname"></label><br>
    <label>สัปดาห์: <input type="week" name="week"></label><br>
    <input type="submit" value="Submit">
  </form>
</body>
</html>

หมายเหตุ: บางเบราว์เซอร์ (Chrome) อาจไม่เคารพ autocomplete="off" สำหรับ Password Fields เพื่อความปลอดภัย