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


被折叠的 条评论
为什么被折叠?



