kiaaanabal
kiaaanabal

Reputation: 384

Wrap text within in a text input

I am needing to wrap text within a text input. I know that textareas have this functionality by default, but I need to use a text input to allow for submit on enter. Pressing enter in a textarea just brings you to a new line.

I've tried word-wrap and word-break, but those don't work.

Upvotes: 0

Views: 129

Answers (1)

Adam Buchanan Smith
Adam Buchanan Smith

Reputation: 9439

Since you cannot wrap an input your best option would be to disable the enter in a text area, see fiddle: https://jsfiddle.net/c259LrpL/11/

<textarea id="something"></textarea>
<script>
$("#something").keydown(function(e){
if (e.keyCode == 13 && !e.shiftKey)
{
  e.preventDefault();
  return false;
  }
});
</script>

Upvotes: 1

Related Questions