I just ran into an odd issue with my CodeIgniter app. I'm using a jQuery .on('submit')
event handler to catch all form submissions and follows this procedure: grab the form object using this
, stores the object for later, checks the user is logged in with an AJAX call, if logged in, gets the stored jQuery form object and submits the form with form.submit()
.
This works absolutely fine for all my forms (form validation works fine, returns validation errors correctly) except when I have a form
with a checkbox
. The checkbox is just ignored.
I use a required
form validation rule to make sure the user ticks the checkbox before continuing and it works absolutely fine when this event handler is disabled however, the validation error only appears (oddly) when I add another input
to the form that isn't a checkbox
!
I'm wondering if there's someone that can understand the theory behind why this error is happening? I could post the code but I'm about 90% sure this is something to do with the way that JavaScript handles posting of checkbox data that I'm just not aware of.
Any ideas?