javascript - Problem when attaching a Custom Validator to a control dynamicly -


anyone have idea why code doesnt work?

<script type="text/javascript">     function bookdeskvalidation(source, arguments) {         var deskcombo = $find("<%=radcomboboxdesk.clientid%>");         var bookcombo = $find("<%=radcomboboxbook.clientid%>");         if (bookcombo.get_text() != "" && deskcombo.get_text() == "") {             arguments.isvalid = false;         }         else {             arguments.isvalid = true;         }     }      function attachvalidator(combobox) {         var validator = document.getelementbyid("<%= customvalidatordeskbook.clientid %>");         validator.controltovalidate = combobox.get_id();         validator.clientvalidationfunction = "bookdeskvalidation";         validatorhookupcontrol(combobox, validator);     } </script>  <td>book:&nbsp;</td>         <td>             <telerik:radcombobox id="radcomboboxbook" runat="server" onclientfocus="attachvalidator">             </telerik:radcombobox>         </td>  <td width="70">desk:&nbsp;</td>             <td width="100">                 <telerik:radcombobox id="radcomboboxdesk" runat="server" onclientfocus="attachvalidator">                 </telerik:radcombobox>             </td> <asp:customvalidator id="customvalidatordeskbook" runat="server"              errormessage="error"              clientvalidationfunction="bookdeskvalidation" forecolor="red">*</asp:customvalidator> 

the onclientfocus fire custom validator doesnt seem attached because no validation done when exit control on validator should attached.

thank you!

ok managed work. here`s did. if knows better way or if did solve problem not right please let me know!

so here's did:

<script type="text/javascript">     function bookdeskvalidation(source, arguments) {         var deskcombo = $find("<%=radcomboboxdesk.clientid%>");         var bookcombo = $find("<%=radcomboboxbook.clientid%>");         if (bookcombo.get_text() != "" && deskcombo.get_text() == "") {             arguments.isvalid = false;         }         else {             arguments.isvalid = true;         }     }      function attachvalidator(combobox) {         var validator = document.getelementbyid("<%= customvalidatordeskbook.clientid %>");         validator.controltovalidate = combobox.get_id();     }      function enablevalidator(combobox) {         var validator = document.getelementbyid("<%= customvalidatordeskbook.clientid %>");         validatorenable(validator, true);     } </script>  <td>book:&nbsp;</td> <td>       <telerik:radcombobox id="radcomboboxbook" runat="server" onclientfocus="attachvalidator" onclientdropdownclosed="enablevalidator">       </telerik:radcombobox> </td> 

so basicly got rid of validatorhookupcontrol function , replaced validatorenable on event onclientdropdownclosed


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -