JavaScript:页面加载时,输入框中会出现一些不需要的文本
在这个页面上,当页面加载时,我重置了所有输入框的值,并将JavaScript:页面加载时,输入框中会出现一些不需要的文本,javascript,html,Javascript,Html,在这个页面上,当页面加载时,我重置了所有输入框的值,并将焦点放在第一个输入框上,例如用户名。但是,在这里,有些不需要的文本会出现,例如user name框中的dwd,以及页面加载时的密码字段中。每当页面加载时,占位符不会出现。这里出了什么错?请看图片 <!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> </head> <b
焦点
放在第一个输入框上,例如用户名
。但是,在这里,有些不需要的文本会出现,例如user name
框中的dwd
,以及页面加载时的密码字段中。每当页面加载时,占位符
不会出现。这里出了什么错?请看图片
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Example</title>
</head>
<body>
<form name="loginForm" method="post">
<input type="text" name="user-name" placeholder="Firstname Lastname"/><br/>
<input type="password" name="password" placeholder="Password"/><br/>
<input type="password" name="password1" placeholder="Confirm password"/><br/>
<input type="email" name="email" placeholder="Email" required/><br/>
<input type="url" name="url" placeholder="Website"/><br/>
<input name="submit" type="submit" value="Submit"/>
</form>
<script type="text/javascript">
window.onload = function(){
document.getElementsByName("user-name")[0].value="";
document.getElementsByName("password")[0].value="";
document.getElementsByName("password1")[0].value="";
document.getElementsByName("email")[0].value="";
document.getElementsByName("url")[0].value="";
document.getElementById("FormSubmit").style.display="none";
document.getElementsByName("user-name")[0].focus();
}
var formElem = document.getElementsByName("loginForm")[0];
formElem.onsubmit = function(){
var returnValue=true;
if (loginForm["user-name"].value.length < 6 ){
returnValue = false;
alert("dshddhhdhdhh");
return returnValue;
}
}</script>
</body>
</html>
引导示例
window.onload=函数(){
document.getElementsByName(“用户名”)[0]。value=“”;
document.getElementsByName(“密码”)[0]。value=“”;
document.getElementsByName(“密码1”)[0]。value=“”;
document.getElementsByName(“电子邮件”)[0]。value=“”;
document.getElementsByName(“url”)[0]。value=“”;
document.getElementById(“FormSubmit”).style.display=“无”;
document.getElementsByName(“用户名”)[0].focus();
}
var formElem=document.getElementsByName(“loginForm”)[0];
formElem.onsubmit=函数(){
var返回值=真;
if(loginForm[“用户名”].value.length<6){
returnValue=false;
警报(“dshdhdhdhh”);
返回值;
}
}
这可能由客户端的密码管理器完成。。。禁用浏览器中的所有扩展名,并尝试在文本输入上放置autocomplete=“off”
属性?