First of all, there is a new attribute autocomplete in HTML5. The autocomplete attribute specifies whether the form should enable autocomplete. It autocomplete allows the browser to predict the input to the field. When the user starts typing in a field, the browser should display options to fill in the field based on the values previously typed.
like:
<form autocomplete=on> First name:<input type=text name=fname /><br /> Last name: <input type=text name=lname /><br /> E-mail: <input type=email name =email autocomplete=off /><br /> <input type=submit /></form><p>Please fill out and submit this form, then reload the page to see how the autocomplete feature works. </p><p>Please note that the form's autocomplete feature is on and the e-mail field is off. </p>
You will find that autocomplete=on will be recorded, but E-mail with autocomplete=off will not be recorded when you enter it again. This is the auto-complete function of form in HTML5!
If you are not sure yet, you can go to the w3school manual to continue learning.
How to turn off autocompleteSometimes we want to turn off the auto-complete function of the input box. For example, when the user enters content, we want to use AJAX technology to search and list from the database instead of searching in the user's history.
There are three ways to turn off the auto-complete function of the input box:
1. Set the contents in the Internet options menu of IE--Autocomplete.
2. Set the Form's autocomplete to on or off to turn on or off the autocomplete function.
(Turn off the entire form auto-prompt function)
3. Set the autocomplete of the input box to on or off to turn on or off the autocomplete function of the input box (turn off the autocomplete of the password field)
Test code: (Enter text in each form and submit it, and then come back to see if it can be completed automatically. Note that the history cannot be completed until it is submitted. There may be errors on the page after submission. Don't worry about it, just go back. Can)
Form with autocomplete enabled<br>
<form name=form1 autocomplete=on> Turn on the input box with autocomplete function <input type=text autocomplete=on ><br> Turn off the input box with autocomplete function <input type=text autocomplete=off><br> <input type =submit value=Submit><br> </form>
Form with autocomplete turned off<br>
<form name=form1 autocomplete=off> Turn on the input box with autocomplete function <input type=text autocomplete=on><br> Turn off the input box with autocomplete function <input type=text autocomplete=off><br> <input type =submit value=submit><br> </form>
Suggestion: Do not turn off all auto-complete functions. Just disable some of the auto-complete functions as needed. If you feel that the browser's built-in auto-complete function is not powerful enough, you can use the jquery plug-in to achieve a more powerful automatic prompt completion function.
For example, the automatic prompt function of Baidu search box is very powerful.
The above is the entire content of this article. I hope it will be helpful to everyone’s study. I also hope everyone will support VeVb Wulin Network.