Make text input fields remember previously entered data

前端 未结 7 1775
夕颜
夕颜 2021-02-18 23:30

My text inputs seem not to remember values that have been typed before. For example, many websites that I don\'t even have an account on, but have, for example entered my email

相关标签:
7条回答
  • 2021-02-19 00:01

    In bootstrap you would fill up the for='' field

    Example:

        <div class="custom-control custom-checkbox checkbox-lg">
          <input type="checkbox" class="custom-control-input" id="TER" value="TER">
          <label class="custom-control-label" for="TER">Land/Lot</label>
        </div>
    

    ^ Notice how for and id values match

    0 讨论(0)
  • 2021-02-19 00:05

    You may try autocomplete="on"

    <input type="text" id="firstName" placeholder="First name" autocomplete="on" />
    
    0 讨论(0)
  • 2021-02-19 00:16

    Add attribute autocomplete="off" to your input.

    0 讨论(0)
  • 2021-02-19 00:17

    In most browsers, you can make your browser display values previously entered in input fields by giving a name to the input. For example:

    <input type="text" id="firstName" placeholder="First name" name="firstName" >
    

    If the field has no name attribute, the browser won't show suggestions.

    Also check if javascript prevents the default action on submit.

    0 讨论(0)
  • 2021-02-19 00:20

    some browsers adamantly refused to remember an input until i "remembered it manually" via (ab)using localStorage... this worked for me:

        {
            // hack to remember last error id on page refresh
            // can't believe i have to do this, but my browser don't want to remember it itself, 
            // ... not sure why
            let $=document.querySelector.bind(document);
            let errorid_element=$("#errorlog_id");
            let rememberHack=function(){
                localStorage.setItem("last_id_remember_hack",errorid_element.value);
            };
            errorid_element.addEventListener("input",rememberHack);
            errorid_element.addEventListener("change",rememberHack);
            errorid_element.value = localStorage.getItem("last_id_remember_hack");
        }
    
    0 讨论(0)
  • 2021-02-19 00:21

    It may vary depending on the browser and user privacy settings and sorts, and it should be on by default, but try adding autocomplete="on" to your input tag.

    0 讨论(0)
提交回复
热议问题