Check if input field value is included in array - Jquery -
i'm trying fire function if input field's value equal of number in array.
i have code below, doesn't seem work!!
var num1 = $("#people-number").val(); var numberarray = [1,3,5,7,9]; if ($.inarray(num1,numberarray) > -1) { $("#valid-people").hide(); $("#non-valid-people").fadein(); }
any tips appreciated.....
it because array has int values , the value testing string
$.inarray(parseint(num1),numberarray)
demo: fiddle