I have a problem with my jQuery code.
I want to check characters from strings which is in array while user typing something in the input.
var postcodes = ["00-240","80","32","90","91"];
$('input[name="text-391"]').keyup(function(){
var header = $('#postalcode').val();
if($('input[name="text-391"]').val().length > 1) {
if($.inArray(header, postcodes) > -1){
alert("None");
}
}
This code checks that all what user type in the input is in array, but i want to check this letter after letter.
For example:
user types: 0 - it's ok
user types: 00 - it's still ok
user types 00-340 - it's not ok and now I want to display warning that we haven't it in the array
user types: 3 - it's ok
user types: 35 - it's not ok, and now i want to display warning that we haven't it in the array
I will be very grateful for any tips. Regards