This is the code that I currently have:
<script>
var zips = ['30068', '90120','30033'];
$(function(){
$('input[name=zip]').change(function(){
var currentVal = $(this).val();
if(!$.inArray(currentVal, zips)){
$('.checkout_button').prop('disabled',true);
} else {
$('.checkout_button').prop('disabled',false);
}
});
});
</script>
I want it so that when the user types in their zip code it sees if we support their service or not. This works currently but only works with 30068. By this, I mean that if I type in 90120 it runs the wrong response unlike 30068. Basically, only the first item of the array correctly works? Why is this?
If You Believe This Is A Duplicate Please Explain So I Can Change My Answer.
if($.inArray(currentVal, zips) === -1){, as it does not return a boolean but an index.