Autocomplete is not working in html with chrome

2019-09-01 08:54发布

Sometimes in my web application even I declare form autocomplete is off sometimes its not working and it autocomplete I typed in my inputs.

Can anyone know how to solved this kind of problem.I use chrome by the way.

sample of my code: sometimes its autocompleting my inputs even I declare turn off already..

<form autocomplete="off" method="post">
    <input autocomplete="off" type="text" name="name">
    <input autocomplete="off" type="text" name="age">
    <input type="submit" >
</form>

3条回答
Summer. ? 凉城
2楼-- · 2019-09-01 09:11
<form autocomplete="off" method="post">
<input autocomplete="off" type="text" name="name"  value="">
<input autocomplete="off" type="text" name="age"  value="">
<input type="submit" >
</form>
查看更多
Viruses.
3楼-- · 2019-09-01 09:11

The solution is simple and working perfectly in all browsers.

  1. Add disabled and autocomplete="off" attribute to the form fields( name, age, etc.)

    <form method="post">
      <input disabled="disabled" autocomplete="off" type="text" class="name" name="name">
      <input disabled="disabled" autocomplete="off" type="text" class="age" name="age">
      <input type="submit" >
    </form>
    
  2. On Page Load enable the fields after few miliseconds.

use the below JS CODE

function getRidOffAutocomplete(){               
    var timer = window.setTimeout( function(){
        $('.name, .age').prop('disabled',false);
            clearTimeout(timer);
        }, 800);
    }

// Invoke the function
getRidOffAutocomplete();
查看更多
时光不老,我们不散
4楼-- · 2019-09-01 09:27

This isn't a bug - autocomplete isn't supported by Chrome any more. It's a design decision by their developers and you should design for it rather than attempting to work around it. See my answer to this very similar question.

查看更多
登录 后发表回答