user1211030
user1211030

Reputation: 3050

Pressing Enter on a <input> submits the wrong <form> (2 forms on 1 page)

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?

Upvotes: 1

Views: 2190

Answers (2)

Jared Drake
Jared Drake

Reputation: 1002

Your second form isn't closed.

Upvotes: 7

user1610684
user1610684

Reputation: 17

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>

Upvotes: 2

Related Questions