The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checkbox validation with JS (RSV)
Hi there,

I want to validate a checkbox group with JS, but when i use the statement:
rules.push("required,accomodationtype[],Please check all that apply");
for this kind of checkbox group:
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_0" value="hotel1">Hotel1<BR>
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_1" value="hotel2">Hotel2<BR>
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_2" value="hotel3">Hotel3<BR>
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_5" value="other"> Other (please specify)<BR>
<INPUT type="text" name="accomodationtypeother" id="accomodationtypeother">

It doesn't validate and it immediately posts the form.
I am not sure if i am doing something wrong.

Can anybody help this situation?

Thanks in advance..
I found the solution by myself Smile

I forgot the slashes, it needs to be like this:
rules.push("required,accomodationtype\[\],Please check all that apply");
This looks like it's on the right track for a situation I'm having, except for one thing:

the name="whatever" within each check box input seems to need to be the same across the check box group in order for the validation to work.

In my case, though, I need for each checkbox to still act independently of each other...needing to have different names attached to each. Long story why...let's just say I have a 3rd party app form tools needs to interact with that requires different database for each check box data.

Any way to group a set of check boxes to validate as a group, but still maintain their individuality? Did that question make sense?
I placed the csv file on the server and created a php file with the recommended codes. However, when I filled out the form and clicked on Submit, the entries were gone but I didn't see the 'Successfully Saved' message, and of course there was no entry into the csv file.

Also when I tested leaving out some fields and clicked on Submit, I did not get the error message in the code. However, I have php 5.11 installed on the computer and all the php forms for another website work well. Do you have any idea what had gone wrong on my side?

Excellent post.I want to thank you for this informative. I really appreciate sharing this great post.
Thanks, I was wondering how to verify if any checkbox selections had been made.
Works fine for me so far.

Forum Jump:

Users browsing this thread: 1 Guest(s)