<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>js 表单验证代码</title>
<script language="网页特效">
function check_value()
{
if(document.login.user.value.length < 1)
{
alert('请输入登陆账号');
document.login.user.focus();
return false;
}
if(document.login.password.value.length < 1)
{
alert('请输入登陆密码');
document.login.password.focus();
return false;
}
}
</script>
</head><body>
<form id="form1" name="login" method="post" action="">
<p>
<label for="textfield"></label>
<input type="text" name="user" id="user" />
</p>
<p>
<input type="text" name="password" id="password" />
</p>
<p>
<input type="submit" name="button" id="button" value="提交" onclick="javascript:return check_value();" />
</p>
<p> </p>
</form>
</body>
</html>