RadDatePicker Validation Problem

2 posts, 0 answers
  1. Sagar
    Sagar avatar
    17 posts
    Member since:
    Sep 2010

    Posted 24 Sep 2011 Link to this post

    When I select date less than mindate or type any string value, raddatepicker shows error which is right but if I click on Save button it goes to server side click event.
    As I expected it won't go to server side event.& this is not compulsory field so i don't want to use requiredfieldvalidator.

    I don't understand,what's the use of Data Input ValidationGroup then?

    Here is my code sample -

    <telerik:RadDatePicker ID="rdpStartDate" MinDate="1900-01-01" runat="server" Width="200px">
                            <DateInput ID="DateInput1" runat="server" ValidationGroup="SafeVault">

    <asp:Button ID="rbtnSave" runat="server" CausesValidation="true" Text="Save"
                            ValidationGroup="SafeVault" OnClick="btnSave_Click" />
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Sep 2011 Link to this post

    Hello Sagar,
    Hook the the client side event OnClientClick to the Submit Button and cancel the postback accordingly.
    Client side:
    function Validate()
           var datepickr = $find('<%= rdpStartDate.ClientID %>');
           if (datepickr.get_dateInput()._invalid==false)
               return false;
           return true;
    <telerik:RadDatePicker ID="rdpStartDate" MinDate="1900-01-01" runat="server" Width="200px">
    <asp:Button ID="Button2" runat="server" Text="OK"  OnClientClick="if(!Validate()) return false;" OnClick="Button2_Click" />

Back to Top