javascript验证密码区分大小写

来源:百度知道 编辑:UC知道 时间:2024/05/28 14:13:37
JSP表单验证
javascript验证密码区分大小写
长度大于五位
如何写
最好用正则表达式

<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function check(){
var psw = document.testForm.testPSW.value;
if(psw.length < 5){
alert("密码长度应该大于5");
return false;
}
if(psw != "aBcDe"){
alert("密码不对(区分大小写)");
return false;
}
}
</script>
</head>
<body>
<form action="noPage" name=testForm>
密码:<input type="password" name=testPSW />
<input type="submit" onclick="return check()" value = "验证" />
</form>
</body>
</html>

<script type="text/javascript">
var validate = function(){
var pwd = document.getElementById("pwd");
if(/^.{5,}$/.test((pwd.value))){
return true;
}else{<