<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=GBK">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<script type="text/javascript">
// 验证输入不为空的脚本代码
function checkForm(form){
if(form.username.value == "") {
alert("用户名不能为空!");
form.username.focus();
return false;
}
if(form.password.value == "") {
alert("密码不能为空!");
form.password.focus();
return false;
}
return true ;
}
</script>
<body>
<form action="login.aspx" method="post" onsubmit="return checkForm(this)" >
<table border="0">
<tr>
<td>用户名:</td>
<td><input type="text" name="username" ></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password" ></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登陆" name="submit1"></td>
</tr>
</table>
</form>
</body>
</html>
写JavaScript的时候总是出错,并且没有发现错误在哪里,以后要多注意