<html>
<head>
<title>第一个HTML文件</title>
<script language="javascript" type="text/javascript">
function loginCheck()
{
var name = document.getElementById("txtName").value;
var password = document.getElementById("txtPassword").value;
if (name == null || name.length <= 0)
{
alert("请输入用户名!");
document.getElementById("txtName").focus();
return false;
}
else if (password == null || password.length <= 0)
{
alert("请输入密码!");
document.getElementById("txtPassword").focus();
return false;
}else{
document.write("<font size='+3' color='green'>欢迎"+name+"你!</font>");
return true;
}
}
</script>
</head>
<body>
<p style="text-align:center; font-size:30px; color:red;">第一个HTML文件 主题头部</p>
<div style="text-align:center;">
<form name="form1" method="post" action="" onSubmit="return loginCheck();">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
用户名:
</td>
<td>
<input type="text" id="txtName" />
</td>
</tr>
<tr>
<td>
密码:
</td>
<td>
<input type="password" id="txtPassword" size="21" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" id="btnOk" value="确定" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>