Possible Duplicate:
Prevent form submission with enter key
In my project, I am trying to disable the Enter key and give my own enter key function.(which I havent done)
The below function is working but whenever I press Enter key inside the TextBox
field, the content is adding to div
(as needed) and also in the TextBox
field, enter key function is happening (which I dont want). How to stop the enter Key function to run on the TextBox
field? For clear understanding please see my comments in the below code.
.aspx file (working)
<asp:TextBox ID="msg" BackColor="Transparent" runat="server" BorderStyle="None"
TextMode="MultiLine" />
jQuery (working)
$('#msg').keypress(function (e) {
if (e.which == 13) {
//Shows the TextBox text in a Div, which I want to.
chat.server.send($('#msg').val()); //also going one step down in TextBox field which I dont want to.
$('#msg').val(''); //Clearing the Text in TextBox field
//what should I add here to make the Enter Key work only for the DIV?
}
});