To autocomplete the value for the Company
or Organization
fields in an input
HTML element, you can add the attribute called autocomplete
with the value of organization
to the input
HTML element using HTML.
TL;DR
<!--
A simple webpage with an `input` HTML
element with autocomplete for the Company
-->
<html>
<body>
<label for="company">Company</label>
<input type="text" id="company" autocomplete="organization" />
</body>
</html>
For example, let's say we have an input
HTML element to accept the Company of the user.
The HTML for that would look something like this,
<!-- A simple webpage with an `input` HTML element -->
<html>
<body>
<label for="company">Company</label>
<input type="text" id="company" />
</body>
</html>
A visual representation of the webpage is shown below,
As you can see from the above GIF that when clicking on the input
HTML element, the autocomplete is not working for the Company
field.
To activate the autocomplete feature, we have to add the autocomplete
attribute with the value of organization
. The organization
value refers that we need to autocomplete the name of Company
for the user.
It can be done like this,
<!--
A simple webpage with an `input` HTML
element with autocomplete for the Company
-->
<html>
<body>
<label for="company">Company</label>
<input type="text" id="company" autocomplete="organization" />
</body>
</html>
Now the webpage looks like this,
As you can see from the above GIF now when clicking on the input
HTML element, a autocomplete dropdown is shown to the user where they can select their company or organization name.
We have successfully added the autocomplete feature and added the value for the Company
input HTML element using HTML. Yay 🥳!
See the above code live in the codesandbox.
That's all 😃.