<script language="javascript">
function SendForm ()
{
if(CheckPost())
{
document.addForm.submit();
}
}
function CheckPost ()
{
if (addForm.user.value == "")
{
addForm.user.focus();
return false;
}
if (addForm.title.value.length < 5)
{
addForm.title.focus();
return false;
}
return true;
}
</script>
<form action="test.php" method="post" name="addForm">
<div>用戶:<input type="text" size="10" name="user" maxlength="20"/></div>
<div>標(biāo)題:<input type="text" name="title" maxlength="50"/></div>
<div>內(nèi)容:<textarea name="content" rows="8" cols="30"></textarea></div>
<div><input type="button" name="submit" value="發(fā)表留言" onclick="SendForm();"/></div>
</form>