invalid date in datepicker

8 posts, 0 answers
  1. newbie
    newbie avatar
    355 posts
    Member since:
    Feb 2008

    Posted 03 Feb 2010 Link to this post

    Currently, if i enter an invalid date in raddatepicker like '019901' then it changes it to 01/01/99'
    Can i give an invalid date message instead and have the user enter the date in the correct format only?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2010 Link to this post

    Hello,

    Try the following approach in order to show error message when typing invalid date in DatePicker.

    ASPX:
     
    <telerik:RadDatePicker ID="textBoxDOB" Skin="Web20" Culture="en-US" runat="server"
        <DateInput ClientEvents-OnError="OnError" runat="server"
        </DateInput> 
    </telerik:RadDatePicker> 

    JavaScript:
     
    <script type="text/javascript"
        Telerik.Web.UI.RadDateInput.prototype.parseDate = function(value, baseDate)   
        {   
            if (new Date(value) != "NaN")   
                return value; 
        } 
        function OnError(sender, args) { 
            alert('Invalid date'); 
        } 
    </script>   

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. newbie
    newbie avatar
    355 posts
    Member since:
    Feb 2008

    Posted 04 Feb 2010 Link to this post

    Hi Shinu,

    This does not work for me.
    I get a js error that 'Telerik.Web.UI.RadDateInput.prototype' is null or not an object'.

    I am using the latest Telerik controls.
    Can you give me a working example?
  5. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 05 Feb 2010 Link to this post

    Hello Anumeha,

    The error is caused by the fact that the RadDatePicker client namespace has not been registered. Probably you are displaying the picker after an AJAX request. If so, you must execute the custom script after the AJAX request, not on initial load. Include the script in another fuction, e.g.


    function executeAfterAJAX()
    {
       if (typeof(Telerik.Web.UI.RadDateInput) != "undefined")
       {
           Telerik.Web.UI.RadDateInput.prototype.parseDate = function(value, baseDate)   
           {   
               if (new Date(value) != "NaN")   
                   return value;
           }
        }
    }


    Kind regards,
    Dimo
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  6. newbie
    newbie avatar
    355 posts
    Member since:
    Feb 2008

    Posted 08 Feb 2010 Link to this post

    I am sorry if I am not getting this right.

    So where should I call the function executeAfterAJAX() ?
  7. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 11 Feb 2010 Link to this post

    Hi Anumeha,

    It depends on your AJAX implementation. For example, you can call the function in the OnResponseEnd handler of RadAjaxManager.

    http://www.telerik.com/help/aspnet-ajax/ajxonresponseend.html

    See also

    http://www.telerik.com/help/aspnet-ajax/ajxcustomjavascript.html

    Regards,
    Dimo
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  8. Howard
    Howard avatar
    2 posts
    Member since:
    Dec 2014

    Posted 15 Jan 2015 Link to this post

    WHY DON'T THESE EXPENSIVE CONTROLS WORK WITH THE .NET VALIDATORS?
  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Jan 2015 Link to this post

    Hi Howard,

    Can I kindly ask you to provide additional details for the issue you are facing with the integration between RadControls and the asp validators controls?

    We do not have some general issues reported for such scenarios and we are not aware of such incompatibility.

    You can check the online demos below that presents the proper behavior of such scenarios:
    http://demos.telerik.com/aspnet-ajax/input/examples/common/validation/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/validation/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/validation/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/calendar/examples/monthyearpicker/validation/defaultcs.aspx

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017