skip to Main Content

I have a textarea that gets processed into an image. I need to force the user to type in a specific area including formatting and returns. The box should limit users from overflowing the box How can this be done?

I’m using cakephp as a framework and can therefore use html, css, php or js to accomplish this.

This is the textarea element I’m working with:

<textarea name="ch_text" id="ch_text" rows="8" tabindex="20"></textarea>

I tried adding a cols property, which didn’t work. I tried setting wrap="true", which didn’t work either. Is there a way to specify a height/width property that can’t be exceeded?

2

Answers


  1. The way I have usually seen this done is by enforcing a character or word limit. This can be done by using variables in the HTML code!

    Login or Signup to reply.
  2. A combination of setting the maxlength on the element and then in CSS make sure to give a height and width and set resize to none.

    textarea {
      resize: none;
      height: 100px;
      width: 200px;
    }
    <textarea maxlength="10"></textarea>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search