Jump to content

make all fields in form autocomplete=off


jasonc

Recommended Posts

I have many fields in my form and wish to know how I can set them all to autocomplete off without using the autocomplete element as this does not validate properly.

 

I have had many people say this is not best practice but still wish to add this to my form.

<script type="text/javascript">
function init() {
if (!document.getElementById) return false;
var f = document.getElementById('auto_off');
var u = f.elements[0];
f.setAttribute("autocomplete", "off");
u.focus();
}
</script>

 

this is what i was first given and have been trying to figure out how i alter this so i can search for all fields and change them without having to add a div to each one as this would be the only way as i have already used the name and the id elements for other things.  also having a script with multiple lines for each and every field is not practicle as there are loads of them.

 

any advise on how i might be able to do this ?

Link to comment
https://forums.phpfreaks.com/topic/237844-make-all-fields-in-form-autocompleteoff/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.