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.
There is no native max-length attribute for textareas.
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.
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.
When there is no max length specified the default is an unlimited number of characters for both textarea and text input.
There's no maxlength
attribute defined for textarea
. You need to implement this using javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With