Pressing Enter on a <input> submits the wron

2019-08-02 20:42发布

I have got two different forms on the same page.

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

and

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

Now when I enter something in <input id="msg"..> and press enter, it submits the second form instead of the first one.

What am I missing?

2条回答
一纸荒年 Trace。
2楼-- · 2019-08-02 21:16

Your second form should by like that

<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>
查看更多
甜甜的少女心
3楼-- · 2019-08-02 21:25

Your second form isn't closed.

查看更多
登录 后发表回答