I have multiple checkbox / textfield related one to each other, PHP generated, with different IDs and names:
<ul>
<li>
<input type="checkbox" name="cb_1" id="cb_1">
<input type="text" name="txt_1" id="txt_1">
</li>
<li>
<input type="checkbox" name="cb_2" id="cb_2">
<input type="text" name="txt_2" id="txt_2">
</li>
...
<li>
<input type="checkbox" name="cb_N" id="cb_N">
<input type="text" name="txt_N" id="txt_N">
</li>
</ul>
When each checkbox is checked, the related textfield should be required
I can do this for one pair, like this:
rules: {
txt_1: {
required: "#cb_1:checked"
}
But how to do for all my N pairs? Is there a simple way or do I have to write validation rules one by one?