开发者

Is there a way to turn off auto-complete on an input-field using jQuery?

Is there a way to turn off auto-complete on an input-field using jQuery开发者_StackOverflow?

Like this:

<input type="text" autocomplete="off" />


$(':text').attr('autocomplete', 'off');


$('input#id').attr('autocomplete', 'off');

You can also use a common class to turn off a group of fields. There are a few ways to do it though as you'll see from the answers.


$('#id').attr('autocomplete', 'off');


For any text field, you could do this.

$("input[type=text]").attr("autocomplete", "off");

Hope this helps!


"autocomplete" isn't a standard attribute. Yes it's implemented, but it's not proper XHTML.

Do you have to do it client-side? Can you make changes on the server-side if necessary?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜