3

Today I want to make an Arabic quiz which it uses input text. Here is my code:

I know it's still basic. But the problem is it can't detect arabic text/language. When I try to input هاي text, it showed "Wrong!" alert. I don't know why it can't detect arabic language. Any solution?

function answer(ans) {
  if (event.keyCode == 13) {
    if (ans.value == "هاي") {
      alert("Right!");
    } else {
      alert("Wrong!");
    }
  }
}
<input type="text" id="answer" style="direction:RTL;"  
onkeydown="answer(this)">
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Sena
  • 178
  • 1
  • 13

0 Answers0