I am calling a function whenever someone press enter in the textarea
. Now I want to disable new line
or break
when enter is pressed.
So new line
should work when shift+enter is pressed. In that case, the function should not be called.
Here is jsfiddle demo: http://jsfiddle.net/bxAe2/14/
try this
update your fiddle to
use the
input
tag instead oftextArea
tag in your HTMLFor Angular Users
While there are existing working solutions, if anyone comes across this question using Angular, you can disable new lines with the following:
Add
<textarea ng-trim="false" ng-model='your.model' ...
In your controller, add: