I have an example code which checks that which user types in the input are available in the javascript array.
var postcodes = ["00-240", "80", "32", "90", "91"];
$('#test').keyup(function () {
var val = this.value;
var m = $.map(postcodes, function (value, index) {
var reg = new RegExp('^' + val + '.*$');
return value.match(reg);
});
$('#msg').text(m.length && val.length ? 'VALID' : 'INVALID');
});
I want to set VALID also when user type: 80-215, 80-512, 32-125 etc. Now if i type 80 or 32 it's display valid but when I write 80-215 or 32-111 it will show invalid. I want to check that some string from the array is available in string which is request from user (with emphasis on the order of letters).
I will be gratefull for any tips.
Regards