浏览器控制台警告错误[DOM] Password field is not contained in a form:或者是 input 警告[DOM]...

本文介绍了两种常见的前端开发中关于密码输入框的警告错误:[DOM]Passwordfieldisnotcontainedinaform和[DOM]Inputelementsshouldhaveautocompleteattributes。针对这些问题,提供了相应的解决方案。对于前者,解决方案是在input标签外添加<form>标签;对于后者,可以在input标签中添加autocomplete属性,例如设置为'off',以关闭自动完成功能。这些修复措施有助于提升网页的规范性和用户体验。

前端编写代码时,查看浏览器控制台会出现的警告错误[DOM] Password field is not contained in a form:或者是 input 警告[DOM] Input elements should have autocomplete attributes (suggested: “new-password”)

1, 出现警告错误[DOM] Password field is not contained in a form:的解决方法是:
在input标签外添加上标签form

<div class="form-group">
              <form>
              密码:
              <input type="password" class="form-control" id="exampleInputPassword1" name="password" placeholder="请输入密码"/>
              </form>
            </div>

2, 出现 input 警告[DOM] Input elements should have autocomplete attributes (suggested: “new-password”)的解决方法:
添加placeholder属性——作用:规定输入字段是否应该启用自动完成功能

<div class="form-group">
              <form>
              密码:
              <input type="password" class="form-control" id="exampleInputPassword1" name="password" placeholder="请输入密码" autocomplete="off"/>
              </form>
            </div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值