javascript检查密码格式的合法性
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script language="javascript">
<!--
function contain(str,charset)
{var i;
for(i=0;i<charset.length;i++){
if(str.indexOf(charset.charAt(i))>=0){
return true;}
}
return false;}
function SetFocus(){
if(document.Login.UserName.value=="")
document.Login.UserName.focus();
else
document.Login.UserName.select();
}
function CheckForm()
{
if(document.Login.UserName.value=="")
{alert("请输入用户名!");
document.Login.UserNmae.focus();
return false;
}
if(contain(document.Login.UserName.value,'<>{}\\'))
{alert("用户名中含有非法字符<>{}\\或空格");
document.Login.UserNmae.focus();
return false;
}
if(documeny.Login.Password.value=="")
{alert("请输入密码!");
document.Login.Password.focus();
return false;
}
if(contain(document.Login.Password.value,'<>{}\\'))
{alert("密码中含有非法字符<>{}\\或空格");
document.Login.Password.focus();
return false;
}
}
-->
</script>
</head>
<body bgcolor="0099ff">
<form name="Login" action="check.asp" method="post" target="_parent" onSubmit="return CheckForm();">
<table width="100%" border="0" cellspacing="8" cellpadding="0" align="center">
<tr align="center">
<td height="38" colspan="2"><font size="3">用户登录</font></td>
</tr>
<tr>
<td align="right">用户名称:</td>
<td><input name="UserName" type="text" id="UserName4" maxlength="20" onFocus="this.select();"></td>
</tr>
<tr>
<td align="right"><span class="style1">用户密码:</span></td>
<td><input name="Password" type="password" maxlength="20" onFocus="this.select();"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Submit" type="submit" value="确 认">
<input name="reset" type="reset" id="reset" value="清 除"><br>
</div></td>
</tr>
</table>
</form>
</body>
</html>
要求对用户输入的用户名和密码的情况作出判断 提示用户是否输入了用户名、密码 提示用户不要讲一些特殊字符作为密码或用户名
实现上述要求要如何进行修改 这个代码只能检测用户名是否为空