Disable New Line in Textarea when Pressed ENTER

try this $(“textarea”).keydown(function(e){ // Enter was pressed without shift key if (e.keyCode == 13 && !e.shiftKey) { // prevent default behavior e.preventDefault(); } }); update your fiddle to $(“.Post_Description_Text”).keydown(function(e){ if (e.keyCode == 13 && !e.shiftKey) { // prevent default behavior e.preventDefault(); //alert(“ok”); return false; } });

Default action to execute when pressing enter in a form

This is not specific to JSF. This is specific to HTML. The HTML5 forms specification section 4.10.22.2 basically specifies that the first occuring <input type=”submit”> element in the “tree order” in same <form> as the current input element in the HTML DOM tree will be invoked on enter press. There are basically two workarounds: Use … Read more

Enter triggers button click

Using <button type=”button”>Whatever</button> should do the trick. The reason is because a button inside a form has its type implicitly set to submit. As zzzzBoz says, the Spec says that the first button or input with type=”submit” is what is triggered in this situation. If you specifically set type=”button”, then it’s removed from consideration by … Read more

Submit form on pressing Enter with AngularJS

Angular supports this out of the box. Have you tried ngSubmit on your form element? <form ng-submit=”myFunc()” ng-controller=”mycontroller”> <input type=”text” ng-model=”name” /> <br /> <input type=”text” ng-model=”email” /> </form> EDIT: Per the comment regarding the submit button, see Submitting a form by pressing enter without a submit button which gives the solution of: <input type=”submit” … Read more

Prevent form submission on Enter key press

if(characterCode == 13) { // returning false will prevent the event from bubbling up. return false; } else{ return true; } Ok, so imagine you have the following textbox in a form: <input id=”scriptBox” type=”text” onkeypress=”return runScript(event)” /> In order to run some “user defined” script from this text box when the enter key is … Read more