I've been working on a postcode checker which I need to have a partial match on the array. ie: if the user current uses L20 it shows true but if the uses L20 1WE if shows false.
I need it to read the array and if any part of the user input matches it shows true.
I have a demo up here: https://codepen.io/paulmaloney/pen/dfa0603f200a8f5be89b0a10d7ba80f6
var postcodes = ["PR8","PR9","WA11","L1","L2","L20","L80"];
$('#searchForm').submit(function(){
var postcode = $('#searchForm input').val();
if($.inArray(postcode.toUpperCase(), postcodes ) > -1){
$('#result').html('Yes, we cover your area!');
}else{
$('#result').html('Sorry, it looks like we do not cover that area yet.');
}
return false;
});
That's my code thus far. I know I'm missing something silly but can't work it out
L20 1WE? I can't understand this part:if the user current uses L20 it shows true but if the uses L20 1WE if shows false