I need to get checkbox values data before form will be submitted using vanilla JS or jQuery, modify and continue submit. For example:
<form name="myForm" method="post">
<input type="checkbox" name="cbxs" value="cb_1">
<input type="checkbox" name="cbxs" value="cb_2">
<button type="submit">Submit</button>
</form>
I need to check if one single checkbox is checked to wrap it with array like cbxs=['cb_1'], if checked 2+ - do nothing. In this case backend is always being received array of checkboxes like cbxs=['cb_1'] or cbxs=['cb_1', 'cb_2'].