0

On my website, users can fill out a form. By default they can skip lines in the form, but how can i prevent this?

this is my code

<div class="form-group">
    <label class="label-main">{{ t('Description') }}</label>
    <textarea name="[description]" class="form-control" placeholder="Your message" rows="7" maxlength="500"></textarea>
</div>

Thanks!

Ruby
  • 3
  • 2
  • Please clearify what you mean by "can skip lines". They can input "empty lines" in the textarea or that they can submit the form without filling out the textarea? – Awita Feb 26 '16 at 13:32
  • when i say "can skip lines" i'm talking about to leave a blank line before starting to type again. (Enter on keyboard) – Ruby Feb 26 '16 at 13:42

1 Answers1

0

There is no HTML-way to achieve this. With e.g. Javascript you could disable the "enter"-key for the textarea or monitor and correct the user input in real time, but that would supposingly confuse the user. Therefore I'd suggest to simply validate the user input (e.g. with Javascript) on form submit and remove all blank lines from the text without bothering the user with it.

This might help you how to do: Javascript: How to use a regular expression to remove blank lines from a string?

Community
  • 1
  • 1
Awita
  • 334
  • 2
  • 8