Show DevBest [jQuery] Disable AutoComplete

Status
Not open for further replies.

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
There's nothing worse than having placed a placeholder attribute in an input field but having it overtaken by something that looks like this:
1352411800-Screenshot_4.png


So with this small script, I'm going to show you how to get from that, to this:
1352411839-Screenshot_5.png


You can do it manually by adding
HTML:
autocomplete="off"
in each element that you want to disable it on, such as:
HTML:
<input type="text" name="username" id="username" autocomplete="off" />

But that's just a pain in the ass, so here is a code that will disable it globally, but you must remember to place the script on every page where you want to disable it, or place it in a JavaScript file and include that file in every page.

Code:
$("input[type='text'], input[type='password'], input[type='email'], input[type='url'], input[type='tel']").each(function(i,a){
    $(a).attr("autocomplete", "off");
});

It only took me 2 minutes to write so I'm not entirely fussed about credits.
 

TyleRJc

Member
Jun 19, 2011
67
12
I like mine having autocomplete on, but I'm sure this will come in handy sometime.
 
Status
Not open for further replies.

Users who are viewing this thread

Top