How can I do this...? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can I do this...?

https://code.sololearn.com/WaHVAVVG08Wh/?ref=app How can I restrict the <text area> characters upto 140 characters? When the user wants to add more than 140 characters, an alert box will pop up and the characters will not be typed.

28th Dec 2017, 10:43 AM
B.D
B.D - avatar
8 Answers
+ 2
yup.. as <textarea maxlength="140"></textarea>
28th Dec 2017, 10:50 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 4
thanks
30th Dec 2017, 5:24 PM
B.D
B.D - avatar
+ 2
In HTML?
28th Dec 2017, 10:49 AM
B.D
B.D - avatar
+ 2
An alert box to pop up before stopping to type the more than 140 characters..?
28th Dec 2017, 10:54 AM
B.D
B.D - avatar
+ 1
use maxlength attribute to limit character length
28th Dec 2017, 10:49 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
And the alert box?
28th Dec 2017, 10:51 AM
B.D
B.D - avatar
+ 1
are you using jQuery?? if so then $( "textarea" ).on('input', function() { if ($(this).val().length>140) { alert('you have reached a limit of 140 characters'); } });
28th Dec 2017, 10:56 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
what changes to alert box??
28th Dec 2017, 10:52 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar