Hi,
I have multiple checkbox groups (Cities) with each having several values (Courses).
So let's say I have two checkbox groups with several courses:
[list]Brussels[list] Course Monday at 19:30 Course Monday at 20:30 [/list][/list]
[list]Brugge[list] Course Wednesday at 20:00 Course Wednesday at 21:00 [/list][/list]
I only want to make the user to choose at least ONE value of all the checkbox group. So in the example at least one (up to 4)
I just want to prevent someone to subscribe and not have selected at least one course in total.
I suspect this has to be done with own validation but I have no idea how to do it for checkbox groups.
I saw the following code in the FAQ for input fields:
Does anyone have an idea how to do it for checkbox groups?
Thanks!
I have multiple checkbox groups (Cities) with each having several values (Courses).
So let's say I have two checkbox groups with several courses:
[list]
[list]
I only want to make the user to choose at least ONE value of all the checkbox group. So in the example at least one (up to 4)
I just want to prevent someone to subscribe and not have selected at least one course in total.
I suspect this has to be done with own validation but I have no idea how to do it for checkbox groups.
I saw the following code in the FAQ for input fields:
function validateOneOf () {
var input_a, input_b;
input_a = jQuery('#phone').val().trim().length;
input_b = jQuery('#email').val().trim().length;
return ( input_a > 0 || input_b > 0 );
}
Does anyone have an idea how to do it for checkbox groups?
Thanks!
Hi Sago,
Give both groups the same name, and in the "Validation rules" box add this:
Best regards,
Max
Give both groups the same name, and in the "Validation rules" box add this:
minChecked[1]:Please select one
Best regards,
Max
Hi Max,
I gave both checkbox groups the same name "Courses[]" and the same id "Courses" as suggested and added the validation rules.
When I check a value of the first checkbox group "Brussels" and try to submit I then get "Please select one" at the top but when I check a value of the 2nd checkbox group "Brugge" and I click submit, the form is send without a problem.
This is what happens when I select one/both value(s) from the first checkbox group. It gets deselected and gives an error.
When I don't check anything I get "Please select one" at the side of the values of both checkbox groups. This error looks a bit different bit different then not selecting anything.
So not sure why it works when checking something from the second group, and not when only checking a value from the first group.
I also realize that if this would work, I will have a problem in my e-mail since the checkbox groups will have the same name.
This is what I used before:
With both names being the same I won't be able to use seperate names with data.join but I can add the name of the cities in the value so that it becomes for example
Brussels Course Monday at 19:30
And I use something like "Selected Courses:" one time in one TR-tag instead having multiple TR's:
I tried this method and selected all values but I only get the two values from the second checkbox group (maybe this is related to why I get an error when I only select a value from the first checkbox group):
This is the test e-mail. As you can see the second paragraph only the values of the second group is send while I check all of them.
This is the link to the small test form: https://tinyurl.com/yczpo8xo
If you fill in your e-mailaddress you will get a copy of the form since I put {data:e-mail} in CC.
Thanks!
I gave both checkbox groups the same name "Courses[]" and the same id "Courses" as suggested and added the validation rules.

When I check a value of the first checkbox group "Brussels" and try to submit I then get "Please select one" at the top but when I check a value of the 2nd checkbox group "Brugge" and I click submit, the form is send without a problem.
This is what happens when I select one/both value(s) from the first checkbox group. It gets deselected and gives an error.

When I don't check anything I get "Please select one" at the side of the values of both checkbox groups. This error looks a bit different bit different then not selecting anything.

So not sure why it works when checking something from the second group, and not when only checking a value from the first group.
I also realize that if this would work, I will have a problem in my e-mail since the checkbox groups will have the same name.
This is what I used before:
<tr>
<td align="right" valign="top" width="30%"><strong>Brussels</strong></td>
<td align="left" valign="top" width="70%"><ul style="margin-top:0px;"><li>{data.join[</li><li>]:CoursesBrussels}</li></ul></td>
</tr>
<tr>
<td align="right" valign="top" width="30%"><strong>Brugge</strong></td>
<td align="left" valign="top" width="70%"><ul style="margin-top:0px;"><li>{data.join[</li><li>]:CoursesBrugge}</li></ul></td>
</tr>
With both names being the same I won't be able to use seperate names with data.join but I can add the name of the cities in the value so that it becomes for example
Brussels Course Monday at 19:30
And I use something like "Selected Courses:" one time in one TR-tag instead having multiple TR's:
<tr>
<td align="right" valign="top" width="30%"><strong>Courses</strong></td>
<td align="left" valign="top" width="70%"><ul style="margin-top:0px;"><li>{data.join[</li><li>]:Courses}</li></ul></td>
</tr>
I tried this method and selected all values but I only get the two values from the second checkbox group (maybe this is related to why I get an error when I only select a value from the first checkbox group):
This is the test e-mail. As you can see the second paragraph only the values of the second group is send while I check all of them.

This is the link to the small test form: https://tinyurl.com/yczpo8xo
If you fill in your e-mailaddress you will get a copy of the form since I put {data:e-mail} in CC.
Thanks!
This topic is locked and no more replies can be posted.