title: Restrict input to a specified language
body: <p>I use a <strong>TextInput</strong> component of Flex 4.5 to enter some text in English. I use the <strong><em>restrict</em></strong> attribute to ... restrict the keyboard input to characters a-zA-Z only. The problem is that if i copy/paste a word in another language, i can then paste it into the TextInput component. Is there a way to avoid that? If no, how can i validate the input against a specified language?</p>
  
  <p>I found out that the unicode set of Chinese+ language symbols is \u4E00 to \u9FFF. So i write the following:</p>
  
  <pre><code>var chRE:RegExp = new RegExp("[\u4E00-\u9FFF]", "g");
  if (inputTI.text.match(chRE)) {
    trace("chinese");
  }
  else {
    trace("other");
  }
  </code></pre>
  
  <p>But if i type in the TextInput the word 'hello' then it validates...What is the error?</p>
  
  <p>Since i cannot (my fault? or a bug?) use unicode range with RegExp, i wrote the following function to check if a word is in Chinese and that's it.</p>
  
  <pre><code>private function isChinese(word:String):Boolean
  {
      var wlength:int = word.length;
      for (var i:int = 0; i &lt; wlength; i++) {
              var charCode:Number = word.charCodeAt(i);
              if (charCode &lt;= 0x4E00 || charCode &gt;= 0x9FFF) {
                      return false;
          }
      }
      return true;
  }
  </code></pre>