Home > Web Front-end > JS Tutorial > body text

Detailed example of jQuery disabling form username and password auto-fill function

小云云
Release: 2017-12-26 14:43:41
Original
2889 people have browsed it

Html login forms are often automatically filled in, and some even have websites where the user has never logged in. This article mainly introduces jQuery's function of disabling automatic filling of usernames and passwords in forms. Friends who need it can refer to it. I hope it can help everyone.

Mozilla developer documentation recommends using the form setting attribute tautocomplete="off" to prevent the browser from getting data from the cache to fill the login form.

<input type="text" name="foo" autocomplete="off" />
Copy after login

But this solution is not compatible with some Chrome and Firefox.

Finally decided to use hidden input to accept browser auto-fill, which will not affect the user experience and is compatible with all browsers.

<input style="display:none"><!-- for disable autocomplete on chrome -->
<input type="text" id="username" name="username" autocomplete="off">
Copy after login

PS: Let’s take a look at the function of preventing the form from automatically filling usernames and passwords

Some browsers support: autocomplete="off"

So the browser supports:

Add the following two codes in the from that will automatically fill in

<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>
Copy after login

Related recommendations:

js method to prohibit form submission

jQuery auto-fill plug-in Cool Auto-Suggest

#php generates thumbnail code to automatically fill in the blanks

The above is the detailed content of Detailed example of jQuery disabling form username and password auto-fill function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!