Pages tagged html5 textarea maxlength

How to limit the max length of input in a textarea

The textarea in HTML is where the user can type in his answers or responses to the queries in free text.

Unlike radio buttons, checkboxes and dropdowns, there are no fixed options, it is like the answer sheets we have during our exams. Wait, we know what you are thinking? "I usually write the same things multiple times for the same question in different ways to ensure the length of my answer goes up, what if the user does the same in the textarea?"

Well, in HTML forms, it would not be the quantity but the preciseness and the quality that will bring us more laurels, and it is highly unlikely that users would fill in long essays in a textarea when they are not getting marks for it, however; the points stands totally valid and as a designer we must be prepared for the worst scenarios.

In fact, the entire use case is totally possible in certain scenarios. One such case would be when the user is submitting a proposal for a job application portal and he needs to fill in the textarea with the question, ‘Tell us about yourself?’

Now, a user might finish this question in one line and another might need more than a thousand to finish the story of his life. However, it is highly unlikely that the reader who is expected to shortlist candidates on the bases on these questions is interested in your life story. Instead, he is interested in a short and precise answer which can help him in analyzing the person and his attributes.

Now, even if the candidates are not willing to take their hands off the lid and limit their storytelling prowess, but we, as web designers, must ensure that we limit their hands and provide a useful platform for both the applicants as well as the company. This is where the maxlength attribute comes to our rescue.

How does the maxlength attribute limit the characters in a textarea?

The maxlength attribute invariable puts the brakes on the free-flowing writer in us and lets us know that the textarea is certainly not the place to try our hands on something new.