I have a form with a text area and hitting the enter key submits my form. How can I make it to add a new line character instead of a form submit.
$(document).ready(function(){
$("#text").keypress(function(event) {
if (event.which == 13) {
var s = $(this).val();
$(this).val(s+"\n"); //\t for tab
}
});
});
This can be done by jquery code that I have given above. Must notice that the use of ready function is necessary when you write above script before the codes of the HTML input field, and not necessary when you write it after the input field codes.If it not working try to use \t in place of \n it will work.