【问题标题】:Pressing Enter on a <input> submits the wrong <form> (2 forms on 1 page)在 <input> 上按 Enter 会提交错误的 <form>(1 页上有 2 个表单)
【发布时间】:2012-08-15 09:48:14
【问题描述】:

我在同一个页面上有两个不同的表单。

<form action="" method="post" onsubmit="ajax_send('<?print $userid;?>',this.msg.value); return false;">
<input id="msg" autocomplete="off" type="text" name="msg" stlye="width: 80px;" autofocus="autofocus" placeholder="Chat here" />
<input type="submit" />
</form>

<form action="?page=about&id=0#comments" method="post">
<textarea class="editbox" id="exitbox" placeholder="Write a comment ..." name="newcomment"></textarea>
<input type="submit" id="submit1" name="submit1"></div></div>

现在,当我在 &lt;input id="msg"..&gt; 中输入内容并按 Enter 键时,它会提交第二个表单而不是第一个表单。

我错过了什么?

【问题讨论】:

标签: php html ajax forms input


【解决方案1】:

您的第二个表单没有关闭。

【讨论】:

    【解决方案2】:

    你的第二种形式应该是这样的

    <form action="?page=about&id=0#comments" method="post">
    <textarea class="editbox" id="exitbox" placeholder="Write a comment ..." name="newcomment"></textarea>
    <input type="submit" id="submit1" name="submit1"></div></div>
    </form>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-04
    • 1970-01-01
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    相关资源
    最近更新 更多