0

When I type the username and password in my login div a popup at the top of the browser appears(Key) and allows us to save the id and password

How do I restrict the browser and not save the Password? I already applied the autocomplete and onfocus="this.removeAttribute('readonly');" strategy, but it is not working for me.

<input type="text" class="form-control input1 input-lg"
                                       autocomplete="off" readonly
                                       onfocus="this.removeAttribute('readonly');"
                                       maxlength="16" id="loginId" placeholder="Enter Username"
                                       onkeypress="return isAlphaNumeric(event)"/>

<input type="password" class="form-control input1 input-lg"
                                       autocomplete="off" readonly
                                       onfocus="this.removeAttribute('readonly');"
                                       onkeypress="return isAlphaNumericWithSpecial(event)"
                                       id="password" placeholder="Enter Password" maxlength="15" onfocus="this.removeAttribute('readonly');"/>

VilleKoo
  • 2,827
  • 2
  • 14
  • 23
  • Does this answer your question? [How to prevent a browser from storing passwords](https://stackoverflow.com/questions/41217019/how-to-prevent-a-browser-from-storing-passwords) – ATP Dec 23 '20 at 08:38

1 Answers1

0

Here is a working solution

<form action='/login' class='login-form' autocomplete='off'>
  Email:
   <input type='email' name='email-entry'>
   <input type='hidden' name='email'>

  Password:
   <input type='password' name='password-entry'>
   <input type='hidden' name='password'>
 </form>

<script>
  $('.login-form').on('submit', function() {
  $('[name="email"]').val($('[name="email-entry"]').val());
  $('[name="email-entry"]').val('');
  $('[name="password"]').val($('[name="password-entry"]').val());
  $('[name="password-entry"]').val('');
   });
</script>

reference

Dj.B
  • 46
  • 3