When there is a long set of elements in a datalist, they will all get displayed with a scroll bar next to them. Is there an easy way to only display the top 5, and just cut the others off?
For example: http://jsfiddle.net/yxafa/
<input type="text" name="search" id="search" placeholder="type 'r'" list="searchresults" autocomplete="off">
<datalist id="searchresults">
<option>Ray0</option>
<option>Ray1</option>
<option>Ray2</option>
<option>Ray3</option>
<option>Ray01</option>
<option>Ray11</option>
<option>Ray21</option>
<option>Ray31</option>
<option>Ray02</option>
<option>Ray12</option>
<option>Ray22</option>
<option>Ray32</option>
<option>Ray012</option>
<option>Ray112</option>
<option>Ray212</option>
<option>Ray312</option>
<option>Ray03</option>
<option>Ray13</option>
<option>Ray23</option>
<option>Ray33</option>
<option>Ray013</option>
<option>Ray113</option>
<option>Ray213</option>
<option>Ray313</option>
<option>Ray023</option>
<option>Ray123</option>
<option>Ray223</option>
<option>Ray323</option>
<option>Ray0123</option>
<option>Ray1123</option>
<option>Ray2123</option>
<option>Ray3123</option>
</datalist>
maxlength="4"
orpattern="Ray[0123]\d"
– Coincidetemplate
tag is only supported in Chrome, Opera Desktop, and Mozilla FF. See here. Same fordatalist
, + partial support for IE 10+ – Drifter