<form name="myform" action="add.php" method="post" onsubmit="return yanzheng();">
标题: <input name="subject" size=40>
内容: <textarea name="content" cols=40 rows=20></textarea>
input type="submit" value="添加">
<input type="reset" value="复原">
<input type=hidden name=type value="$type">
</form>
标题: <input name="subject" size=40>
内容: <textarea name="content" cols=40 rows=20></textarea>
input type="submit" value="添加">
<input type="reset" value="复原">
<input type=hidden name=type value="$type">
</form>
怎么回事?
<?
/* filename:form.php */
?>
<script language="javascript">
function yanzheng()
{if (document.myform.subject.value=="")
{alert("标题不能为空");return false;}
if (document.myform.content.value=="")
{alert("内容不能为空!");return false;}
return true;
}
</script>
<?php
echo ("<form name='myform' action='add.php' method='post'>
标题:
<input name='subject' size='40'><br>
内容:
<textarea name='content' cols='40' rows='20'></textarea><br><br>
<input type='submit' value='添加' onclick='javascript:return yanzheng();'>
<input type='reset' value='复原'>
<input type='hidden' name='type' value='$type'>
</form>");
?>
执行:http://host.name/form.php
经过测试!(WIN2K+IIS5+PHP4)