So i have a list of check boxes created through unique values of a query. Once i have these values i was to check and make sure the user has checked at least one before being able to submit the form to be exported as an excel document. if they have not checked one box then i was it to send an alert and cancel the submit.
here is my script:
document.getElementById('btnPrint').onclick = function(){
var checkOperator = $('input[name="OperatorName[]"]:checked').length;
if(!checkOperator){
alert('It worked!')
return false;
}
return true;
};
<input type="submit" name="btnSubmit" value="preview" onclick="submitForm('index.php')"/>
<input type="submit" id="btnPrint" name="btnSubmitPrint" value="print" onsubmit="submitForm('exportExcel.php')"/>
what's happening now is that it is still exporting to excel and not showing the alert and canceling.