This is a migrated thread and some comments may be shown as answers.

RadDatePicker Custom validator onclick of button

1 Answer 273 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sucheta Patil
Top achievements
Rank 1
Sucheta Patil asked on 01 Oct 2010, 12:30 PM
Hi guys,
I have a RadDatePicker (txtDOB) and it is a mandatory field.
I have used the RFV for txtDOB which validates txtDOB but
I have a search button which searches for the DOB and returns some value.
If I enter 'abcdefg' in txtDOB and click Search button it gives me 
        Nullable object must have a value.

What is the custom validator in Javascript to validate alphabets and invalid input on click of button.
I have seen your demo which did not help me.Here is my code below.......
<li>
         <asp:Label ID="lbDOB" runat="server" Text="Date of Birth: (dd/mm/yyyy)"  
             AssociatedControlID="txtDOB" Height="35px" Width="300px"></asp:Label>         
         <telerik:RadDatePicker ID="txtDOB" runat="server" DateFormat="dd/MM/yyyy" 
             Culture="English (United Kingdom)" Width="125px" MinDate="01/01/1950 00:00:00" 
                         
         </telerik:RadDatePicker>             
       <asp:Button ID="btnSearch" runat="server" CausesValidation="true" 
           Text="Search" onclick="btnSearch_Click" />  
            <asp:RequiredFieldValidator ID="RFV_txtDOB" runat="server" 
             ControlToValidate="txtDOB" ErrorMessage="Please enter DOB" 
             ValidationGroup="DateValidate" Font-Size="Large" SetFocusOnError="true" Display="dynamic">*</asp:RequiredFieldValidator>          
          
    </li>
.
Please help me.
S

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Oct 2010, 01:01 PM
Hello,



Give a try with the folowing code in ClientValidationFunction of CustomValidator and see whether it helps.

Client code:
<script type="text/javascript"
    // ClientValidationFunction of CustomValidator 
    function ClientValidationFunction1(sender, args) { 
        var datepicker = $find("<%=RadDatePicker1.ClientID%>"); 
        if (datepicker.get_dateInput()._invalid) { 
            alert("Invalid"); 
            args.IsValid = false
        
    }   
</script>


Thanks,
Princy.
Tags
General Discussions
Asked by
Sucheta Patil
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or