嗨,你写的代码,这对我很有帮助,但我想在innerHTML中显示消息时密码不匹配如何做到这一点我正在尝试但不为我工作。下面是我的代码。请引导我。我是初学者。javascript密码如果不匹配显示在innerHTML
if (pwd != cpwd) {
document.getElementById("pwd").innerHTML="password must be match";
document.getElementById("cpwd").innerHTML="password must be match";
document.getElementById("pwd").style.color="RED";
return false;
}
我想知道如何在innerHTML的
正好在下面写代码
<input id="pass1" type="password" placeholder="Password" style="border-radius:7px; border:2px solid #dadada;" /> <br />
<input id="pass2" type="password" placeholder="Confirm Password" style="border-radius:7px; border:2px solid #dadada;"/> <br />
<script>
function myFunction() {
var pass1 = document.getElementById("pass1").value;
var pass2 = document.getElementById("pass2").value;
if (pass1 != pass2) {
//alert("Passwords Do not match");
document.getElementById("pass1").style.borderColor = "#E34234";
document.getElementById("pass2").style.borderColor = "#E34234";
}
else {
alert("Passwords Match!!!");
}
}
透过
感谢提前 等待您的欣赏答案。
[Your code seems to work](http://jsfiddle.net/UA9q8/)。什么是'cpwd'和'pwd'?你有什么问题? –
你想放哪里..你的“pwd”和“cpwd”元素在哪里 – user2587222