Skip to content Skip to sidebar Skip to footer

Force Autocomplete="off" On Whole Html Document

Is there a way to set autocomplete='off' as standard behaviour to every element on the whole HTML document at once? (I am not looking for a way to do this for a single element) I a

Solution 1:

You can simply do this using jquery. Try below -

$(document).ready(function(){
   $( document ).on( 'focus', ':input', function(){
     $( this ).attr( 'autocomplete', 'off' );
   });
});

OR you can try this -

$(document).ready(function(){ 
    $("input").attr("autocomplete", "off");
}); 

The browser autocomplete is unrelated to the browser cache. The cache saves the actual data sent to the browser by web sites - i.e. the HTML code, CSS, Javascript and images. The autocomplete is a browser feature that saves what the user types into forms.

Setting "no-cache" will not stop autocomplete, it will just stop the browser saving the page to the user's computer. If the page itself contains possibly sensitive information (outside of the form), then use it, otherwise it the user must download the page every time they visit it, using more bandwidth for them and the server.

Post a Comment for "Force Autocomplete="off" On Whole Html Document"