I'm trying to validate input using JavaScript, what i want is to bring up an alert if the user enters something that is not included in my array.
Here is what i have so far
var validAr = ["1","2","3","4","5","6","7","8","9","10","m","M"];
//dont mind the i it's been previously declared
val =+ document.getElementById('arrow_' + i + '_1').value
alert(val);
alert(validAr.indexOf(val));
If for example in the above the user enters '5' I'll alert '5', the value of val and then -1 which means that it does not belong to the array. How do I solve this?