Javascript 输入类型密码不工作自动完成=";关「;使用Angularjs
我使用了Javascript 输入类型密码不工作自动完成=";关「;使用Angularjs,javascript,jquery,html,css,angularjs,Javascript,Jquery,Html,Css,Angularjs,我使用了autocomplete=“off”,但没有使用密码输入,请检查下面我的演示代码 <form name="testfrm" ng-submit="test(testfrm)" autocomplete="off"> <input type="password" id="passwordFiled" name="test" autocomplete="off" required> <button type="submit" c
autocomplete=“off”
,但没有使用密码输入,请检查下面我的演示代码
<form name="testfrm" ng-submit="test(testfrm)" autocomplete="off">
<input type="password" id="passwordFiled" name="test" autocomplete="off" required>
<button type="submit" class="btn"> test </button>
</form>
测验
请告诉我如何为密码字段禁用自动完成功能您可以为密码字段添加名称更改功能,这可能是一个可行的解决方案,以下是我尝试的代码:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
// Returns random string based on 32 different characters and 4 dashes ("-")
function string_generator() {
var str = function() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return (str() + str() + "-" + str() + "-" + str() + "-" + str() + "-" + str() + str() + str());
}
$(document).ready(function() {
$("#passwordField").attr("name", string_generator());
});
</script>
</head>
<body>
<form name="testfrm" ng-submit="test(testfrm)">
<input type="password" id="passwordField" name="test" autocomplete="off" required>
<button type="submit" class="btn"> test </button>
</form>
</body>
</html>
//返回基于32个不同字符和4个破折号(“-”)的随机字符串
函数字符串_生成器(){
var str=函数(){
返回((1+Math.random())*0x10000)| 0.toString(16)子字符串(1);
};
返回(str()+str()+“-”+str()+“-”+str()+“-”+str()+“-”+str()+“-”+str()+str()+str());
}
$(文档).ready(函数(){
$(“#passwordField”).attr(“name”,string_generator());
});
测验
让我知道它是否有效(如果不起作用,请检查密码字段id,因为在我的代码中是“passwordField”,而在你的代码中是“passwordField”)
无论如何,如果您需要原始名称测试作为url变量,那么这个答案应该是无用的配置您的浏览器不存储密码,然后呢?不要试图搞乱我想如何在浏览器中处理我的密码。强迫用户以某种方式处理事情,仅仅因为你认为这是正确的,实际上并不能增加安全性;通常情况下可能恰恰相反。@CBroe Yes man你是对的,但是如果你身边有任何自动完成的解决方案,请告诉我这是否回答了你的问题?