لماذا نستخدم الإكمال التلقائي = {قيمة أخرى غير التشغيل/الإيقاف} في HTML؟

برمجة


can anyone tell me why we need to use values of autocomplete other than on/off (like given-name, family-name, new-password,etc.) because i found out that form will be autofilled only when name attribute form exactly matches perviously stored value having same name attribute (e.g. if my form has name="fname" than autocomplete only work when contains previously stored data in which fname="naresh" and it will suggest naresh) also if name attribute not present id attribute should be same. this will happen when autocomplete=on and works same if autocomplete=other_value_except_off then why we use these values (given-name,etc.).

ما حاولت:

i have created two files input1.html and input2.html. autocomplete only works if name attributes are same no effect of autocomplete - input1.html:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form>
    <label for="firstname">first name: </label><input type="text" id="firstname" name="fname" autocomplete="given-name">
    <br>
    <label for="lastname">last name: </label><input type="text" id="lastname" name="lname" autocomplete="family-name">
    <input type="submit">
  </form>
</body>

</html>
input2.html:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form>
    <label for="firstname">first name: </label><input type="text" id="firstname" name="firstname"
      autocomplete="given-name">
    <br>
    <label for="lastname">last name: </label><input type="text" id="lastname" name="lastname"
      autocomplete="family-name">
    <input type="submit">
  </form>
</body>

</html>
here if i filled form in input1.html and then open input2.html - no suggetions but if i changed name of input2.html to fname and lname then i will suggestions. what is the role of autocomplete here. i better use autocomplete=on then why we need other values i am using this in google chrome

الحل 1

"on"

يُسمح للمتصفح بإكمال الإدخال تلقائيًا. لا يتم تقديم أي إرشادات فيما يتعلق بنوع البيانات المتوقعة في هذا المجال، لذلك قد يستخدم المتصفح حكمه الخاص.

إذا كنت تستخدم “on” فقط، فيجب على المتصفح تخمين نوع البيانات التي تتوقعها في الحقل.

إذا كنت تستخدم قيمة أكثر تحديدًا، فأنت تخبر المتصفح صراحةً بنوع البيانات الموجودة في الحقل، لذلك لا يحتاج إلى التخمين.

コメント

タイトルとURLをコピーしました