为什么不调用javascript啊~!!

来源:百度知道 编辑:UC知道 时间:2024/05/09 02:06:34
代码如下:
<script language="javascript">
<!--
function CheckForm() {
if (login.username.Value == ""){
alert("用户名不能为空;");
document.login.username.focus();
return false;
}
if (login.password.Value == ""){
alert("密码不能为空;");
document.login.username.focus();
return false;
}
return true;
}//--></script>
<form method="post" name="login" onsubmit="return CheckForm();" action="login.asp">
<table width="229" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="64"><div align="right">用户名:</div></td>
<td width="159"><input name="username" type="text" id="username"></td>
<

login.username.value 小写value

新修改的
<script language="javascript">
<!--
function CheckForm() {
var str=document.getElementById("username").value
if(str=="")
{
alert("用户名不能为空!");
document.getElementById("username").focus()
return false;
}
var str1=document.getElementById("password").value
if(str1=="")
{
alert("密码不能为空!");
document.getElementById("password").focus()
return false;
}

}//--></script>
<form method="post" name="login" onsubmit="return CheckForm();" action="login.asp">
<table width="229" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="64"><div align="right">用户名:</div></td>