Autocomplete=”off” workaround / fix for valid XHTML
Add an onload function similar to the following to <head> section of your web page.
<script type="text/javascript">
function onload_call() {
if (!document.getElementById) return false;
var f = document.getElementById('field_name');
f.setAttribute("autocomplete", "off");
}
</script>
Call onload_call() function as page/body onload call as below and you are done.
<body onload='onload_call()'> <input type='text' id='field_name' value='' /> Field label
If you are on jQuery you can add a similar snippet of js code to below to your webpage (anywhere at a valid place of course)
$(document).ready(function() {
$("#field_name").attr("autocomplete", "off");
});
Possibly Related posts:
- Gmail like ajax loading message at the top of page
Here is a sample javascript code to show Gmail like “Loading.. Please wait..” message at the top of a HTML page while making Ajax requests.... - jQuery pop up message box sliding from left to right and positioning horizontally at the center
Just wrote a simple sliding box script to make a message box appear sliding from left to the middle of web page. The box appears... - How to check radio button on page load with jQuery
For example you have a set of radio buttons created dynamically with some web language like PHP and you expected one of them selected or...
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.






Alternative for jQuery;
$(function(){$(“#field_id”).attr(“autocomplete”, “off”);});