I am struggling with this one a bit because my javascript skills are lacking.
Essentially I have a form that I do not want submitted, if a citizen does not select a tool to rent. Making the checkbox a required field won't work as some will be unchecked always.
My current JS hides the submit button quite well, but does not unhide it after the DB lookups (for current inventory)
.toolInventory is the table
.checkMe is the checkboxes themselves
$(document).ready(function() {
$('.Submit').hide();
$('.toolInventory .checkMe').click(function () {
var anyChecked = false;
$('.toolInventory .checkMe').each(function() {
if ($(this).is(':checked') && $(this).val() === 'Check_Out') {
anyChecked = true;
return false; // Exit early if any checkbox is slected
}
});
if (anyChecked) {
$('.Submit').show();
} else {
$('.Submit').hide();
}
});
});
What it currently does:
I appreciate any insight/advice. My backup plan is to have the workflow determine if no values were selected, and then dump the process. But that just seems unnecessary if I can control it from the front end.
Thank you.