I'm trying to check if the value of an input field is in the array but it doesn't seem to work.
This is what I have tried:
var postcode1 = [];
for (var i = 21000; i < 21999; i++) {
postcode1.push({ val: i, text: i });
}
console.log(postcode1);
$('#fw_form_field_146').blur(function() {
var val = $("#fw_form_field_146").val();
if( $.inArray(val, postcode1) > -1 ) {
alert('test');
}
});
The array is outputting in console.log but the check doesn't work when i fill in the input field.