Search code examples
htmlinternet-explorerformsusability

disable autocomplete/pre-populate in IE via HTML?


Demo link: http://elevation-inc.com/dev/test/ieform/

In IE 6/7/8 - if you enter a term into a simple input field, submit the form and then hit the back button - the input field retains the previously submitted term. If you then refresh the page, the value is also retained.

How, via HTML, can this pre-population be disabled? We want no value to be in the input box on page load/domready.

We've already tried autocomplete='off' on both the form and input element, but the pre-population is still persisting.

Thanks in advance.


Solution

  • Well I guess it's a browser behaviour you can't bypass by html. You can do it in javascript however:

    <script>
    window.onload = function() { document.forms.f.q.value = ""; };
    </script>
    

    or if you don't want to wait for images to load (because window.onload will wait for that), you can use the document ready event, as described here. (it needs more tweaking to make it work across all browsers)