【发布时间】:2022-09-30 19:56:44
【问题描述】:
我编写了这段代码来验证密码,我需要向用户显示两个不同的警报。
1. (pw.length < 8) when this condition executed \"Password need minimum 8 characters\"
2. (pw != cpw) \"Passwords does not match\"
<script>
function validatePassword(){
var pw= document.getElementById(\"txtPassword\").value;
var cpw= document.getElementById(\"txtCPassword\").value;
if((pw.length < 8)||(pw != cpw))
{
alert(\"please enter the correct password\")
return false;
Event.preventDefault();
}
return true;
}
</script>
有没有人知道有什么...
-
您需要显示 2 个警报吗?因为如果 txtPassword 无效,则可以忽略 txtCPassword。
标签: javascript validation if-statement