title: How can i validate the input from a html5 Datalist?
body: <p>I would like to know how I can validate the input value that comes from a <code>Datalist</code>. I mean, if I have a <code>Datalist</code> where the user can start to write a value and then choosing it from the <code>Datalist</code>, but the user decides to don't choose any value from the list and he submits the form with the incomplete value, the sent value will be wrong.</p>
  
  <p>I thought about iterate over all the elements of the <code>Datalist</code> but I think that it can't be a good idea if the <code>Datalist</code> has more than 1.000 values and I don't know any other way to validate it.</p>
  
  <p>Here is an example of the <code>Datalist</code> that I'm going to use:</p>
  
  <pre><code>&lt;input type="text" list="colours"&gt;
  
  &lt;datalist id="colours"&gt;
      &lt;option value="Red" data-id="1"&gt;
      &lt;option value="Blue" data-id="2"&gt;
      &lt;option value="Green" data-id="3"&gt;
      &lt;option value="Black" data-id="4"&gt;
      &lt;option value="White" data-id="5"&gt;
  &lt;/datalist&gt;
  </code></pre>