Author - StudySection Post Views - 71 views

Create Autocomplete Input In HTML


The autocomplete attribute specifies whether a form or an input field should have autocomplete on or off. It allows the browser to predict the worth. When a user starts to type into a form field, the browser displays options to fill within the field, carrying earlier typed values.

How to Use:

Create an HTML file in local machine and add this code in the created file:

<!doctype html>
<html lang="en">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->

<link rel="stylesheet" href=""/>
<link rel="stylesheet" href=""/>

<div class="col autocomplete-input">
<div class="ui-widget d-flex">
<label for="tags">Type to search:</label>
<div class="input-group custom-input">
<input type="text" class="form-control" id="tags" value=""> </div>

<script src=""></script>
<script src=""></script>
<script src=""></script>

Use the CDN for bootstrap 4 CSS, jquery and jqueryUI. jqueryUI CSS or jquery CDN is mainly used to create this input in HTML. This is your basic input field output without any autocomplete functionality.



This is a simple layout you have created in the HTML file with Bootstrap 4.
You can add the below code for required jquery functionality of autocomplete input types. Add this code below to jquery links in the bottom of page :

$(function () {
var list = [
source: list,
minLength: 0,
$(this).autocomplete("search", "");
jQuery.ui.autocomplete.prototype._resizeMenu = function () {
var ul =;


Note :
Highlighted code in bold: This code is for showing autocomplete list on focus.
Highlighted code in italic: This code for adjusting autocomplete list width according to the input box.



This is the basic use of jQuery UI input in HTML code with focus.

If you have skills in PHP programming and you want to enhance your career in this field, a PHP certification from StudySection can help you reach your desired goals. Both beginner level and expert level PHP certification exams are offered by StudySection along with other programming certification exams.

Leave a Reply

Your email address will not be published.