"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Monday, January 7, 2013

Turn off autocomplete for textbox in ASP.Net using jQuery

Turn off auto-complete for text-box in ASP.Net using jQuery

Its all about handling autocomplete attribute,It can be done by javascript or implicit given as false



jQuery code to turn off autocomplete for ASP.NET textbox.

$(document).ready(function(){
  $("#<%=Textbox.ClientID %>").attr("autocomplete", "off");
});

But there is no need to use jQuery for this as this can be done easily just by setting attribute for ASP.NET textbox.

<asp:TextBox runat="server" ID="Textbox" autocomplete="off"/>

But jQuery can be useful, if there are many ASP.NET textboxes then jQuery can be useful. Instead of setting attribute for every textbox can take time but using jQuery you can turn off using jQuery.


If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

2 comments:

a said...

You can also set autocomplete attribute to form to turn off autocomplete all textboxes at once.

< form id="form1" runat="server" autocomplete="off">

SImplyAsp said...

@vinay :: if you are adding autocomplete off on form that means entire form auto-complete feature is disabled.Not for a particular textbox.

in jquery

$("*").attr('autocomplete', 'off');

like this