2

I have a form on my settings page which provides users to change their password. My problem here is an input field for old password automatically gets the value of username of user logged_in and new password field gets the password. I tried changing all input types of text and it solved my problem seems browser supposes a text field followed by password field as login form. But I want to set the input type for old password to text. How do I get empty input fields?

<form action="" method="post">
   <label>Old Password</label> <input type="text" name="oldpassword">
   <label>New Password</label> <input type="password" name="newpassword">
   <label>Confirm Password</label> <input type="password" name="newpassword2">
</form>
bɪˈɡɪnə
  • 1,057
  • 1
  • 18
  • 44

2 Answers2

3

You have to turn autocomplete off, but this might be frowned upon by many other users who use this to store their password:

<form action="" method="post">
  <label>Old Password</label> <input autocomplete="off" type="text" name="oldpassword">
  <label>New Password</label> <input autocomplete="off" type="password" name="newpassword">
  <label>Confirm Password</label> <input autocomplete="off" type="password" name="newpassword2">
</form>

And do you use type="text" for oldpassword? Looks like a typo for me. Please correct.

Also, in Chrome, there's a problem with autocomplete. You might need to use some fake fields. See Disabling Chrome Autofill for more information.

Community
  • 1
  • 1
Praveen Kumar Purushothaman
  • 154,660
  • 22
  • 177
  • 226
1

Use autocomplete and there are three ways to disable autocomplete

First one in input:

<input type='text' autocomplete='off' />

Second one in form:

<form action='' autocomplete='off'>

Third one in javascript:

$('input').attr('autocomplete', 'off');
devpro
  • 15,966
  • 3
  • 25
  • 38