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


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

java - How to create Table using Apache PDFBox -

mpi - Why is MPI_Bsend not returning error even when the buffer is insufficient to accommodate all the messages -