All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

Disable AutoComplete Form Using jQuery

Last Updated : Jul 1, 2023

IN - jQuery HTML | Written & Updated By - Anjali

When you type in any form field by default you will see word suggestions based on your previous submitted text sometimes user don't want to see these suggestions so in this tutorial we will show you how to disable autocomplete form using jQuery.

You may also like autocomplete textbox using jQuery, PHP and MySQL.

Disable AutoComplete Form Using jQuery

To Disable AutoComplete Form It Takes Only One Step:-

  1. Make a HTML file and define markup, scripting and styling

Step 1. Make a HTML file and define markup, scripting and styling

We make a HTML file and save it with a name disable_autocomplete.html

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function disable_autocomplete()
{
 $("#form1").attr('autocomplete', 'off');
}	
</script>
<style>
body
{
 text-align:center;
 width:100%;
 margin:0 auto;
 padding:0px;
 font-family:helvetica;
 background-color:#6AC993;
}
#wrapper
{
 text-align:center;
 margin:0 auto;
 padding:0px;
 width:995px;
}
#form1 input[type="text"]
{
 width:300px;
 height:40px;
 padding-left:10px;
}
#form1 input[type="submit"]
{
 margin-top:10px;
 width:110px;
 height:40px;
 background-color:#2F6145;
 border:none;
 color:white;
 font-size:15px;
 box-shadow:0px 3px 0px 0px #224933;
 border-radius:3px;
}
#form1 input[type="button"]
{
 margin-top:10px;
 width:190px;
 height:40px;
 background-color:#2F6145;
 border:none;
 color:white;
 font-size:15px;
 box-shadow:0px 3px 0px 0px #224933;
 border-radius:3px;
}
</style>
</head>
<body>
<div id="wrapper">

<form id="form1">
 <input type="text" name="text" placeholder="Enter Text">
 <input type="submit" value="Submit">
 <input type="button" value="Disable AutoComplete" onclick="disable_autocomplete();">
</form>

</div>
</body>
</html>

// To Disable Particular Text Field
<input type="text" autocomplete="off">

In this step we create a form to submit text and to show word suggestion in second time we create a button to disable autocomplete form.

We create a function disable_autocomplete() and we just simply add autocomplete off attribute to our form using jQuery. You may also like enable disable submit button using jQuery.

Thats all, this is how to disable autocomplete form using jQuery. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

I hope this tutorial on disable chrome autofill programmatically helps you and the steps and method mentioned above are easy to follow and implement.