I have an issue with a textarea that is defined on an asp.net page. The textarea is populated in the back end with text read directly from an mssql database.
<div id="emailForm" runat="server" style="display:inline;">
<textarea name="Body" id="Body" rows="20" cols="20">
text in here
<textarea>
</div>
The following CSS is applied to the emailForm div:
padding: 5px;
width: 750px;
font-family: Lucida Sans, Verdana, Arial, Helvetica, sans-serif;
font-size: 0.9em;
margin: 0px 0px 10px 0px;
border: 2px solid #ccc;
and to the textarea itself:
height: 360px;
Some users have reported that whilst they can edit the text within the textarea they cannot get the return key to function. New lines cannot be added?
I've search the net but cant find an example of this happening. If anyone has any bright ideas i'd love to hear. Thanks.
To add to Christoffer's Answer, if you are facing same problem you can solve it by replacing the following code:
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
with this one:
$(window).keydown(function(event){
if((event.which== 13) && ($(event.target)[0]!=$("textarea")[0])) {
event.preventDefault();
return false;
}
});
this would allow the textarea to have enter (new line), still preventing the enter key for the rest.
Your code is correct exept the closing tag of the textarea :
</textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With