I have a form on my site, and I need to change the response just for people who enter one of a few zip codes. I'm trying to set the code up to check the first 3 digits of the entered zip code against the objects saved in my array. It's not finished yet, but I'm testing it as I go along and right now I'm trying to get the zipValue to show in the console once someone clicks off of the zip field, but I'm not having any luck getting it to work. This is what I have so far -
let inLA = false;
var zipsLA = ["700, 701, 703, 704, 705, 706, 707, 708, 710, 711, 712, 713, 714"];
const $zipField = document.getElementById('formFieldZip')
const $zipValue = document.getElementById('formFieldZip').value
$zipField.addEventListener('blur', function(){
console.log(zipValue);
});
My eventual hope is that if the first 3 digits of the entered zip code match an entry in the array, it will set 'inLA' to true.
Edit: Fiddle link: https://jsfiddle.net/zdy9sgbn/