title: Latin Characters check
body: <p>there are some similar questions out there, but none that are quite the same or that have an answer that works for me.</p>
  
  <p>I need a javascript function which validates whether a text field contains all valid latin characters, so no cryllic or Chinese, just latin; specifically:</p>
  
  <blockquote>
    <p>Basic Latin (excluding the C0 control characters), Latin-1 (excluding
    the C1 control characters), Latin Extended A, Latin Extended B and
    Latin Extended Additional. This set corresponds to Unicode code points
    U+0020 to U+007E, U+00A0 to U+024F and U+IE00 to U+IEFF</p>
  </blockquote>
  
  <p>Some of the answers out there seem to check the first character in the text field but miss out others, so these are no good.</p>
  
  <p>This is what I have tried so far (this doesn't work!):</p>
  
  <pre><code>var value = 'abcdef' // from text field
  var re = '\u0000-\u007F|\u0100-\u017F|\u0180-\u024F|\u1E00-\u1EFF|\u0080-\u00FF'; // latin regexp string
  // var re = '\\w+/'; // alternative
  if (new RegExp(re).test(value)) {
      result = false;
  }
  </code></pre>
  
  <p>The following sort of works but only for the first character:</p>
  
  <pre><code>//var re = '\u0000-\u007F|\u0100-\u017F|\u0180-\u024F|\u1E00-\u1EFF|\u0080-\u00FF'; // latin regexp string
  // couldn't get the above to work so using the following:
  var re = '\\w+';
  if (!value.match(re)) {
      message = 'Please enter valid latin characters only';
      $focusField = $this;
  }
  </code></pre>
  
  <p>What is the right way to do this?</p>
  
  <p>I really need code, rather than an explaination, but both would be better.</p>
  
  <p>Thanks</p>