<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function check(f)
{
if(f.test.value=="")
{
alert('值不能为空!');
return false;
}
}
</script>
</head><body>
<form id="form1" name="form1" method="post" action="" onsubmit="return check(this)">
<input type="text" name="test" />
<input type="submit" name="Sub" value="提交" />
</form>
</body>
</html>