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 –
<input type="text" id="txtAccountNumber" autocomplete="off" />
<form id="frmAccount" autocomplete="off"></form>
window.onload = function()
document.getElementById('frmAccount').setAttribute('autocomplete', 'off'); // Here frmAccount indicates id of the form.
Hope this will help you.