I have this array :
array = ['08','06','05','03','123456'];
when I enter values into a text input I'm checking if there are in the array. This appears to be working.. but I'm finding it's matching on 07 and 123 as well as the values in the array.
$(function() {
$('#do').on('input', function() {
array = ['08','06','05','03','123456'];
do = $(this).val();
if ($.inArray(do, array) > -1) {
$(this).css('background-color', '#FFFFFF');
console.log (do + ' - ' + array + ' - not found');
} else {
$(this).css('background-color', '#FAFAFA');
console.log (do + ' - ' + array + ' - found');
}
});
});
I've created a fiddle, to show this.
All I'm trying to do is change the css background of the input if the value entered in 'do'
matches any whole value in the array. If it doesn't match then change the background white.
The array values are coming from php and are formatted as :
['08','06','05','03','123456']
I can change the array layout if needed.
Can any one advise what I'm doing wrong.
Thanks