Block textarea | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Block textarea

Hi every body please how I Can Prevent Entry in a Textarea on HTML and CSS ?

17th Jul 2017, 9:00 AM
ADAMOU AMADOU Abdoul Razak
ADAMOU AMADOU Abdoul Razak - avatar
6 Answers
+ 2
thanks
17th Jul 2017, 10:19 AM
ADAMOU AMADOU Abdoul Razak
ADAMOU AMADOU Abdoul Razak - avatar
+ 2
#Peshkawt Mahmood wrote: << but its better to use javascript to prevent editing >> Why do do you think it's better? @@
17th Jul 2017, 10:55 AM
visph
visph - avatar
+ 2
how to do it with JS?
17th Jul 2017, 11:06 AM
ADAMOU AMADOU Abdoul Razak
ADAMOU AMADOU Abdoul Razak - avatar
+ 2
With JS you can simply do: <textarea oninput="this.value='';"></textarea> ... but it's not a good idea: the 'readonly' boolean attribute is well suited for that purpose, and in case of no JS allowed in browser (not available or desactivated by user) the expected behaviour will be lost ;P If for some reasons the 'readonly' attribute don't give your expected behaviour, try to implement it in pure Html/Css rather than with JS: https://code.sololearn.com/WjK5ZU6GQ3b0/?ref=app (the code sample use an <input> but the Html/Css workaround could be adapted to a <textarea> element)
17th Jul 2017, 11:40 AM
visph
visph - avatar
0
you can add readonly property in html <textarea id="mytext" readonly></textarea> but its better to use javascript to prevent editing
17th Jul 2017, 9:24 AM
Peshkawt Mahmood
Peshkawt Mahmood - avatar
0
Blocked Textarea Code : <textarea style=""rows=""disabled>Texts</textarea>
7th Jun 2022, 8:06 PM
aliz6398suisiTerminatorEmpireBot
aliz6398suisiTerminatorEmpireBot - avatar