javascript - Using jQuery to populate ValidatorHookupControl -
i have following form items:
medications: <asp:radiobuttonlist id="meds" runat="server" repeatdirection="horizontal"> <asp:listitem value="1">yes (list below)</asp:listitem> <asp:listitem value="0">no</asp:listitem> </asp:radiobuttonlist> medication list: <asp:customvalidator id="val_medslist" runat="server" clientvalidationfunction="check_medslist" onservervalidate="val_medslist_servervalidate" validationgroup="groupsave" validateemptytext="true" errormessage="required" controltovalidate="medslist" enableclientscript="true"> </asp:customvalidator><br /> <asp:textbox id="medslist" cssclass="jquerymedslisttarget" textmode="multiline" runat="server" width="500" maxlength="500" wrap="true" rows="3" />
the idea if "yes" selected textbox needs filled out , opposite true if "no" selected. in order have "yes"/"no" options trigger custom validator use 'validatorhookupcontrol' such:
validatorhookupcontrol(document.getelementbyid('meds_0'), document.getelementbyid('val_medslist')); validatorhookupcontrol(document.getelementbyid('meds_1'), document.getelementbyid('val_medslist'));
this works me, become annoying when have more 2 options. created following loop through of options doesn't seem work ("yes" , "no" not trigger custom validator):
$(document).ready(function () { hookupradiobuttonlisttoval($('input[id^=meds_]'), $('#val_medslist')); }); function hookupradiobuttonlisttoval(rbl, validator) { $(rbl).each(function () { validatorhookupcontrol($(this), $(validator)); }); }
i assume not returning correct type of element $(this)
, $(validator)
not sure go there.
the final solution ended being
function hookupradiobuttonlisttoval(rbl, validator) { $(rbl).each(function () { validatorhookupcontrol(this, $(validator)[0]); }); }
this uses idea jbabey shared tweak validator portion. unfortunately if called validatorhookupcontrol(this, validator);
typeerror: val.style undefined
Comments
Post a Comment