javascript - Disable input auto complete on React.js - Stack Overflow

I know this has been asked a 1000 times, but all the answers say the same yet neither work for me at al

I know this has been asked a 1000 times, but all the answers say the same yet neither work for me at all.

Here'm my input field:

  <input
    className={
      required ? "input-field__input input-field__input--required" : "input-field__input"
    }
    id={placeHolder}
    type={type}
    placeholder={placeHolder}
    autoComplete="new-password"
    value={value || ""}
    onChange={e => handleChange(e.target.value)}
  />

I've tried autoComplete="new-password", autoplete="new-password", autoComplete="none" & autoplete="none" but chrome keeps showing me sugestions based on past inputs, no matter which one I've tried. Is there something else happening that might affect it?

I know this has been asked a 1000 times, but all the answers say the same yet neither work for me at all.

Here'm my input field:

  <input
    className={
      required ? "input-field__input input-field__input--required" : "input-field__input"
    }
    id={placeHolder}
    type={type}
    placeholder={placeHolder}
    autoComplete="new-password"
    value={value || ""}
    onChange={e => handleChange(e.target.value)}
  />

I've tried autoComplete="new-password", autoplete="new-password", autoComplete="none" & autoplete="none" but chrome keeps showing me sugestions based on past inputs, no matter which one I've tried. Is there something else happening that might affect it?

Share Improve this question asked Apr 1, 2020 at 11:03 TsabaryTsabary 3,9985 gold badges40 silver badges92 bronze badges 2
  • 1 possible duplicate of stackoverflow./questions/15738259/disabling-chrome-autofill – Maielo Commented Apr 1, 2020 at 11:05
  • Nothing works. Tried to generate a unique input for that autoplete fields as well by providing it the current timestamp in milliseconds, but still got auto plete. – Tsabary Commented Apr 1, 2020 at 11:17
Add a ment  | 

3 Answers 3

Reset to default 5

Add autoComplete="off" in the form tag instead of the input tag. Below is the code to follow :-

  <form autoComplete="off">
          <input id="input" type="text" placeholder="Enter Text" />
  </form>

{autoComplete} syntax i.e camelCase for React, html follow {autoplete} in lowercase. JSX also convert it to lower case. You can see the rendered DOM.

Here is the demo :- https://codepen.io/gahlotbaba/pen/JjdzmmB?editors=0111

Hope it helps.

you can add a dummy invisible input above your password

    <div style={{ height: 0px; overflow: hidden; background: transparent; }}>
        <input type="password"></input>
    </div>

autoComplete="new-password" should work for you.

this will remove the autoplete

more on this here

https://github./react-toolbox/react-toolbox/issues/1795

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744944852a4602549.html

相关推荐

  • javascript - Disable input auto complete on React.js - Stack Overflow

    I know this has been asked a 1000 times, but all the answers say the same yet neither work for me at al

    2天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信