How to disable Chrome autocomplete feature?

后端 未结 6 1312
花落未央
花落未央 2021-02-19 07:09

We want to disable autocomplete in Chrome browser in our React JavaScript application. We have tried bunch of solution available on the Internet but nothing wor

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 07:44

    You can override chrome autofill by add onFocus attribute.

    render()
    {
      return 
    }
    
    

    In the onFocus method we need to change "autocomplete" attribute through javaScript.

    onFocus = event => {
    
       if(event.target.autocomplete)
       {
         event.target.autocomplete = "whatever";
       }
    
    };
    

    This solution works for me.

    let me know if it works for you ;)

提交回复
热议问题