Disable AutoComplete Textbox In Your Website

Disable Autocomplete TextBox in Websites:

Here in this article i am going to discuss about how to dissable the autocomplete textbox in websites.This is a very basic and important concept i am going to discuss.I have involved in working with several websites,while creating a website we need not pay attentation about several small mistake,but this would be vary dangerous while move to the production.

So here i am going to discuss such a issue which need to pay attentation while developing.Here i am showing what actually autocomplete of a textbox.

Here i have created Login Form which i have shown below.
Here is the Html code for this webform.
  1. <body>  
  2.     <form id="form1" runat="server">  
  3.         <div style="margin-left:200px;margin-top:200px; background-color:azure;width:300px">  
  4.             <table>  
  5.                 <tr>  
  6.                     <td>  
  7.                         UserId:  
  8.                     </td>  
  9.                     <td>  
  10.                         <asp:TextBox runat="server" ID="txt_userid"></asp:TextBox>  
  11.                     </td>  
  12.                 </tr>  
  13.                 <tr>  
  14.                     <td>  
  15.                         Password:  
  16.                     </td>  
  17.                     <td>  
  18.                         <asp:TextBox runat="server" ID="txt_password" TextMode="Password"></asp:TextBox>  
  19.                     </td>  
  20.                 </tr>  
  21.                 <tr>  
  22.                     <td>  
  23.                         <asp:Button runat="server" ID="btn_submit" Text="submit" />  
  24.                     </td>  
  25.                 </tr>  
  26.             </table>  
  27.         </div>  
  28.     </form>  
  29. </body>  
We can dissable this autocomplete in two label.
  1. In browser Label

  2. In Coading Label
  • Using AutoCompleteType="Disabled" of a textbox.
  • Using autocomplete="off" of a textbox.
  • Setting form autocomplete="off".
  • setting textbox attribe.
  • Using Jquery.

In browser Label

Here i am going to show how to dissable in browser Label.

Go to the Browser Setting.



Go to the Advance Setting and Check for Passwords and Forms.
Unckeck the the two checkbox.

 
Then Reset all changes.



After that open that open the Login page and type that no auto suggesation will found. So in this way we can dissable the autocomplete in browser label.
In Coading Label

By making AutoCompleteType="Disabled",
  1. <asp:TextBox runat="server" ID="txt_userid" AutoCompleteType="Disabled"></asp:TextBox>  
By setting autocomplete="off",
  1. <asp:TextBox runat="server" ID="txt_userid" autocomplete="off"></asp:TextBox>  
By Setting Form autocomplete="off",
  1. <form id="form1" runat="server" autocomplete="off">  
  2. //your content  
  3. </form>  
By using code in .cs page,
  1. protected void Page_Load(object sender, EventArgs e)   
  2. {  
  3.     if (!Page.IsPostBack)  
  4.     {  
  5.         txt_userid.Attributes.Add("autocomplete""off");  
  6.     }  
  7. }  
By Using Jquery 
  1. head runat = "server" >  
  2.     < title > < /title> < script src = "Scripts/jquery-1.6.4.min.js" > < /script> < script type = "text/javascript" >  
  3.     $(document).ready(function()  
  4.     {  
  5.         $('#txt_userid').attr('autocomplete''off');  
  6.     });  
  7. //document.getElementById("txt_userid").autocomplete = "off"  
  8. < /script>  
and here is my textbox in <body>,
  1. <asp:TextBox runat="server" ID="txt_userid" ></asp:TextBox>  
By Setting textbox attribute in code,
  1. protected void Page_Load(object sender, EventArgs e)   
  2. {  
  3.     if (!Page.IsPostBack)  
  4.     {  
  5.         txt_userid.Attributes.Add("autocomplete""off");  
  6.     }  
  7. }  
So in this way we can dissable autocomplete textbox in webform.After dissabling the text will not appear.