0

I want to disable autocomplete feature of web browsers by using autocomplete="off". I tried with this attribute and working fine for my local machine but when i deploy the same code on server and when i access the same page with my local machine's browser(The same chrome browser that i confirmed with earlier and working as expected) it seems autocomplete is not disabled and prompting for saving of username and password.

<!DOCTYPE html>
<html>
<head>
    <title>Form, autocomplete html5</title>
</head>
<body>
    <form action="" autocomplete="off">
        <table>
            <tr>
                <td>
                    <label>First Name:</label>
                </td>
                <td>
                    <input type="text" name="fname">
                </td>
            </tr>
            <tr>
                <td>
                    <label>Last Name:</label>
                </td>
                <td>
                    <input type="text" name="lname">
                </td>
            </tr>
            <tr>
                <td>
                    <label>Email ID:</label>
                </td>
                <td>
                    <input type="text" name="email">
                </td>
            </tr>
            <tr>
                <td>
                    <label>Password:</label>
                </td>
                <td>
                    <input type="password" name="pwd">
                </td>

            </tr>
            <tr>
                <td> </td>
                <td>
                    <input type="submit">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

I expect the exact reason that after making the page live by deploying it on server why does it not works and working fine for my local machine. My Browser info is "Version 75.0.3770.100 (Official Build) (32-bit)". What might be the necessary steps in order to make this correct.

Fitzi
  • 1,641
  • 11
  • 17
  • Try to inspect the form and check for the attribute for the deployed site on the server – weegee Jul 02 '19 at 08:23
  • I did the inspection and even that attribute autocomplete="off" is appearing in browser but still it doesn't work. While with the same inspection if i run this html on local machine working perfectly, but the same code doesn't obey autocomplete="off" when run from server despite appearing autocomplete="off" in debug mode. – indal kumar yadav Jul 02 '19 at 09:32

1 Answers1

1

As stated in the MDN article about autocomplete:

In most modern browsers, setting autocomplete to "off" will not prevent a password manager from asking the user if they would like to save username and password information, or from automatically filling in those values in a site's login form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#Values

You could work around this by setting the autocomplete property for the password field to new-password as stated here: https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion#Preventing_autofilling_with_autocompletenew-password

In general I would advise to keep the autocompletion though, since preventing functionality a users except leads to bad user experience in the most cases.

Fitzi
  • 1,641
  • 11
  • 17