HTML使用JavaScript禁止浏览器自动填写用户名密码
内容摘要
很多人都在问这个HTML使用JavaScript禁止浏览器自动填写用户名密码
文章正文
很多人都在问这个HTML使用JavaScript禁止浏览器自动填写用户名密码,那么接下来直接写代码:
HTML:
< div class = "form-floating mb-3" > < input type = "tel" name = "username" class = "form-control" id = "username" placeholder = "手机号" readonly = "readonly" > < label for = "floatingInput" >手机号</ label > </ div > < div class = "form-floating mb-3" > < input type = "password" name = "password" class = "form-control" id = "password" placeholder = "设置密码" readonly = "readonly" > < label for = "floatingPassword" >设置密码</ label > </ div > |
JavaScript:
<script> setTimeout( function removeReadonly(){ var username=document.getElementById( "username" ); var password=document.getElementById( "password" ); username.removeAttribute( "readonly" ); password.removeAttribute( "readonly" ); },1000); </script> |
代码注释
[!--zhushi--]