Currently I am using an autocomplete box within an HTML form.
where "val" contains the contents of the text field:
for (i = 0; i < arr.length; i++)
{
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase())
{
...code to create drop down list...
}
}
But this only works with matching patterns from the start. Would like to use RegEx instead to select any array items that contain val anywhere in the array.
I have tried
var results = arr[i].match(/val/i);
if (var)…
But obviously that has failed.
Obviously I could modify the second if statement to loop through the entire length of the array variable, but that would be a waste of time.
Can someone help me with the current usuage?