Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text Area maxlength not working

Tags:

html

I want to set maximum length to the textarea. I am using following code for the same,but it is not working,

<textarea name="txtDescription" cols=10 rows=3 maxlength=50></textarea>

But it is not working,it takes characters beyond 50.

like image 224
Sachin R Avatar asked Aug 16 '10 08:08

Sachin R


People also ask

Does Maxlength work on textarea?

There is no native max-length attribute for textareas.

How do I restrict length of textarea?

Note − By default, we can enter data in a textarea upto 5,24,288 characters. In some cases, there is a need of putting a limit on the size of characters that can be typed in a textarea. So in that case, we can use maxlength attribute to control the number of characters entered in a textarea.

How do you limit the number of characters entered a textarea in an HTML form?

You can limit this by setting maxlength attribute on textarea tag like <textarea maxlength="120"></textarea> in HTML and additionally "cut" input string in PHP by substr() function.

Is there any limit in HTML textarea?

When there is no max length specified the default is an unlimited number of characters for both textarea and text input.


1 Answers

There's no maxlength attribute defined for textarea. You need to implement this using javascript.

like image 134
Darin Dimitrov Avatar answered Jun 26 '23 22:06

Darin Dimitrov