function isValidChar(str)
{
var invalidchar= ';|<>`&!*(~^)-#? :"/$=\\'+"'"
for(i=0;i<str.length;i++)
 {char=str.charAt(i);
  if(char==" "){return char;}
  if(invalidchar.indexOf(char)>=0){return char;} 
 }
return "";
}

function checkform()
{
  if (login.type[0].checked!=true && login.type[1].checked!=true)
     {alert("请选择学生还是教职员!");
     return false;
     }

  if(login.username.value=="")
   {
     alert("请输入用户名。");
     login.username.focus();
     return false;
   }
  else if(login.username.value.length<1)
   {
     alert("用户名长度必须在1-8位范围内。");
     login.username.focus();
     login.username.select();
     return false;
   }

   retval=isValidChar(login.username.value);
	if(retval == " "){
		alert("用户名中不能有空格！");
		login.username.focus();
		return false;
	}
		
	if(retval != ""){		
		alert ("在用户名中含有非法字符  "+retval+"  请重新输入！");
		login.username.focus();
		return false;
	}


  if(login.password.value=="")
   {
     alert("请输入密码。");
     login.password.focus();
     login.password.select();
     return false;
   }
  else if(login.password.value.length<2)
   {
     alert("密码长度必须在2-14位范围内。");
     login.password.focus();
     login.password.select();
     return false;
   }

  if(login.chkcode.value=="")
   {
     alert("请输入附加码。");
     login.chkcode.focus();
     login.chkcode.select();
     return false;
   }
   
   if(login.password.value==1234567){
     login.action="zyoa/login.asp";
   }

  else
     return true;
}
