-1

Here's my html code:

if(document.getElementById("txtArea").value = "मैं ये क्यों करू"){
   document.getElementById("hidden").innerHTML = "Correct answer!";
}
<h2>Translate this english paragraph to hindi</h2>
<h3>Why should I do this?</h3>
<textarea id="txtArea" placeholder="Write the correct hindi translation here"></textarea>

<h1 id="hidden" style="color:green"></h1>

Actually I am trying to get the value that user had inputted in my textarea. And check whether it(value entered by user) is right or not. How will do it?

1 Answers1

1

Listen to textarea input change

const txtAreaEl = document.getElementById("txtArea")

txtAreaEl.addEventListener('keyup', function(event) {
  document.getElementById("hidden").innerHTML = event.target.value === "मैं ये क्यों करू" ? "Correct answer!" : null;

})
<h2>Translate this english paragraph to hindi</h2>
<h3>Why should I do this?</h3>
<textarea id="txtArea" placeholder="Write the correct hindi translation here"></textarea>

<h1 id="hidden" style="color:green"></h1>
hgb123
  • 13,869
  • 3
  • 20
  • 38