<form action="res.php" method="post" name="myform" onbsumit="return checkdata();"> //onsubmit 拼写有误

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta name="author" content="">
    </head>
    <script language="javascript">
    function checkdata()
    {
    first=document.myform.txt_fname.value;
    if(first==null || first=='')
    {
    alert("is null!");
    return false;
    }
    else
    document.myform.submit();
    }
    </script><body>
    <form action="res.php" method="post" name="myform">
    <table align="center" width="500px" border="1">
    <tr><td>first</td><td><input type="text" name="txt_fname"></td></tr>
    <tr><td>last</td><td><input type="text" name="txt_lname"></td></tr>
    <tr><td>position</td><td><input type="text" name="txt_position"></td></tr>
    <tr><td>address</td><td><textarea rows="4" name="txt_address"></textarea>
    <tr><td colspan="2" align="center">
    <input type="button" value="query" onclick="checkdata()">
    &nbsp;&nbsp;<input type="reset">
    </td></tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    onbsumit="return checkdata();">
    onsubmit
      

  3.   

    呵呵,路过,学习一下,正在研究php和js之间的变量传值呢。