+ 2
How I can ckeck the contenent of a textarea?
Hey! I have a problem. I want to check the contenent of a textarea whit javascript. I maked that : HTML : <textarea id="a"></textarea> <input type="submit" onclick="go()"> Javascript : const text = document.getElementById("a"); function go(){ if(text == "ah"){ alert("test") } } Somebody can help me?
6 Answers
+ 4
const text = document.getElementById("a");
function go(){
if(text.value == "ah"){
alert("test")
}
}
+ 3
https://code.sololearn.com/WhxPUg3jQ2us/?ref=app
as you can see, doing as Mohamed ELomari suggested
(text.value) will solve your problem
+ 1
I think you have to put a .value after the GetElementById to get the contents of the textarea
+ 1
Ok =/ Because on pgone it doesn't work .... I will use inputs (idk why but whit inputs it work...)
- 1
No, he dind't work....
- 1
Anwriter and the reader of my phone..