Hi,
I have a rad combobox and i need to make a textbox as a required field if a particular item was selected in the combobox.
I have the following code:
| <td valign="top" style="font-weight: normal" class="ms-formbody"> |
| <%-- <asp:DropDownList ID="ddlReferralSource" runat="server" Width="132"> |
| </asp:DropDownList>--%> |
| <telerik:RadComboBox runat="server" ID="radComboReferralSource" AllowCustomText="false" |
| EnableLoadOnDemand="false" MarkFirstMatch="true" OnClientSelectedIndexChanged="ValidateHearAboutUsSource" > |
| </telerik:RadComboBox> |
| <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="radComboReferralSource" |
| Display="Dynamic" SetFocusOnError="true" ErrorMessage="<%$Resources:CareerResources, Career_RequiredField%>" |
| ValidationGroup="profile" InitialValue="<%$Resources:CareerResources, Career_SelectText%>"></asp:RequiredFieldValidator> |
| </td> |
| <td> |
| <asp:TextBox runat="server" ID="txtHearAboutUsSourceValue"></asp:TextBox> |
| <asp:RequiredFieldValidator runat="server" ID="rfvHearAboutUsSourceValue" ControlToValidate="txtHearAboutUsSourceValue" |
| Display="Dynamic" SetFocusOnError="true" ErrorMessage="<%$Resources:CareerResources, Career_RequiredField%>" |
| ValidationGroup="profile" ></asp:RequiredFieldValidator> |
| </td> |
as soon as i add the OnClientSelectedIndexChanged attribute, the dropdown doesnt even open on the page.
so i have two questions:
- How to solve the problem with dropdown in the rad combobox?
- How to force client side validation for a particular textbox if a particular value is selected in the radcombobox?
Update: I am now able to view the dropdown values but they are not triggering the ValidateHearAboutUsSource function.
| <script type="text/javascript" language="javascript"> |
| function ValidateHearAboutUsSource(item, eventArgs) { |
| alert("test"); |
| var item1 = eventArgs.get_item(); |
| alert("You selected " + item1.get_text()); |
| var dropdownvalue = item.value; |
| alert(dropdownvalue); |
| var textBoxItem = document.getElementById('<%=txtHearAboutUsSourceValue.ClientID%>' |
| var validator = document.getElementById('<%=rfvHearAboutUsSourceValue.ClientID%>'); |
| } |
| </script> |
Thanks
Vishesh