var Values = []; $("input[name^='productids']").each(function() { var val = $.trim(this.value); if (val == "" || isNaN(val)) { Values = []; //Clear our values return false; //Stop looping } else { Values.push(val); //Save } }); if (Values.length == 0) { alert("Invalid Entries!!"); } else { //Do stuff with array "Values", which has what the user entered }
On Jan 12, 7:54 pm, Costaud <cost...@gmail.com> wrote: > Hello, > > How can I make sure all the below fields are filled with integers or > return false and show a simple alert message if it's not: > > <input type="text" name="productids[1]" value="" size="3" /> > <input type="text" name="productids[2]" value="" size="3" /> > <input type="text" name="productids[3]" value="" size="3" /> > > Your help would be greatly appreciated.