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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.