You might have noticed that in various sites if you give your UserID first time, the next time you come to fill your UserID, the browser auto-suggestions it.
Of course you can clear your browser’s form data (in IE) or form & search history (in Firefox) but wouldn’t it be better if we turn this feature off ? This especially becomes a necessity when inputing sensitive data such as bank account number, Debit/Credit Card number etc on a shared computer. In such cases, another user at a later time visiting the same site would be presented with your data through autocomplete suggestions.
So how do we prevent browsers from suggesting it ?

The solution is to add autocomplete=”off” attribute to textbox tag, which will help to stop auto suggestion behaviour for that particular textbox.
And if you want to stop that behaviour for all the textboxes that are present inside a form then add autocomplete=”off” attribute to form tag..

According to HTML specifications, autocomplete is an unrecognized attribute which was originally created by Microsoft (feature of remembering what you have entered in previous text fields with the same name, available first in Internet Explorer) and has adopted by all other major modern browsers (except Opera).
After adding this attribute to any textbox or to any form it will look like –

After adding this attribute, it might invalidate your HTML page. So the work around for this is to add autocomplete attribute to an element through javascript.
You can do it by writing the following piece of javascript code –