Javascript - Detect Arabic Text

こ雲淡風輕ζ 提交于 2019-12-12 14:16:43

问题


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)">

来源:https://stackoverflow.com/questions/34567135/javascript-detect-arabic-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!