Using jQuery to populate ValidatorHookupControl
<p>I have the following form items:</p>

<pre><code>Medications:    
&lt;asp:RadioButtonList ID="meds" runat="server" RepeatDirection="Horizontal"&gt;
     &lt;asp:ListItem Value="1"&gt;Yes (list below)&lt;/asp:ListItem&gt;
     &lt;asp:ListItem Value="0"&gt;No&lt;/asp:ListItem&gt;
&lt;/asp:RadioButtonList&gt;

Medication List:
&lt;asp:CustomValidator ID="val_medsList" runat="server" ClientValidationFunction="check_medsList" 
   OnServerValidate="val_medsList_ServerValidate" ValidationGroup="GroupSave" ValidateEmptyText="true"
   ErrorMessage="required" ControlToValidate="medsList" EnableClientScript="true"&gt;
&lt;/asp:CustomValidator&gt;&lt;br /&gt;
&lt;asp:TextBox ID="medsList" CssClass="jQueryMedsListTarget" TextMode="MultiLine" runat="server" 
    Width="500" MaxLength="500" Wrap="true" Rows="3" /&gt;
</code></pre>

<p>The idea is if "Yes" is selected the textbox needs to be filled out and the opposite is true if "No" is selected. In order to have the "Yes"/"No" options trigger the custom validator I use 'ValidatorHookupControl' as such:</p>

<pre><code>ValidatorHookupControl(document.getElementById('meds_0'), document.getElementById('val_medsList'));
ValidatorHookupControl(document.getElementById('meds_1'), document.getElementById('val_medsList'));
</code></pre>

<p>This works for me, but this will become annoying when I have more than two options. I created the following to loop through all of the options but it doesn't seem to work ("yes" and "no" do not trigger the custom validator):</p>

<pre><code>$(document).ready(function () {
    hookupRadioButtonListToVal($('input[id^=meds_]'), $('#val_medsList'));
}); 
function hookupRadioButtonListToVal(rbl, validator) {
    $(rbl).each(function () {
        ValidatorHookupControl($(this), $(validator));
    });
}   
</code></pre>

<p>I assume I am not returning the correct type of element with <code>$(this)</code> and <code>$(validator)</code> but not sure where to go from there.</p>
