新手,请高手指教!!!
我自己写了一个简单的 JAVASCRIPT脚本验证,但是不知道为什么就是错误!!给指点并给出相关的资料!!谢谢
<script language= "javascript ">
<!--
function checkspace(checkstr)
{
var str= ' ';
for (i=0;i <checkstr.length();i++)
{
str=str+ ' ';
}
return (str==checkstr);
}
function ad_check()
{
if(checkspace(document.adminform.admin.value))
{
document.adminform.admin.focus();
alert( "管理员不能为空! ");
return false;
}
if(checkspace(document.adminform.pasword.value))
{
document.adminform.pasword.focus();
alert( "密码不能为空 ");
return false;
}
document.adminform.submit();
}
-->
</script>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 管理员登录 </title>
<style>
table{background-color:#999933;margin-left:auto;margin-right:auto;margin-top:}
.adminhead{font-size:10px;font-color:#ccddff;font-family: "楷体_GB2312 ";align= "center "}
</style>
</head>
<body>
<form action= "checkadmin.asp " method= "post " name= "adminform ">
<table align= "center ">
<tr>
<td> <div style= "adminhead "> 后台登录 </div> </td>
</tr>
<tr>
<table align= "center ">
<tr> </tr>
<tr>
<td> <div style= "adminhead "> 管理员: <input type= "text " name= "admin " id= "admin " size= "12 "> </div> </td>
</tr>
<tr>
<td> <div style= "adminhead "> 密 码: <input type= "password " id = "pasword " name= "pasword " size= "12 "> </div> </td>
</tr>
<tr>
<td colspan= "2 " align= "center "> <input type= "button " onClick= "return ad_check() " name= "sb " value= "登录 ">
<input type= "reset " name= "rs " value= "重置 "> </td>
</tr>
</table>
</tr>
</table>
</form>
</body>
</html>
------解决方案--------------------checkstr.length() ——〉checkstr.length