I have order form with multiple inputs (only 4 for testing purposes), what I’m trying to achieve is that when any of these inputs are 0 or empty you are not able to submit form (basically you have to order at least 1 item). I have something similar (function checkEmpty) that I was using for a while with similar form, but as I'm very new to jQuery I have problem adopting it to jQuery and current code.
Testing jsfiddle: http://jsfiddle.net/nitadesign/97tnrepg/19/
function checkEmpty(){
var inputs = document.forms['packaging'].getElementsByTagName('input');
var noneZeroFound = false;
for(var i=0;i< inputs.length;i++){
var input = inputs[i];
if(input.value != '0'){
noneZeroFound = true;
break;
}
}
if(!noneZeroFound ){
alert('You have to order minimum 1 product.');
return false;
}
return true;
}