<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>

解决方案 »

  1.   

    可是我写的那个如果不用php就可以正常弹出对话框~
    怎么回事?
      

  2.   

    将以下代码COPY过去试试:
    <?
    /* 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)