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

invalid date in datepicker

7 Answers 411 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 04 Feb 2010, 12:39 AM
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?

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Feb 2010, 05:54 AM
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.
0
newbie
Top achievements
Rank 1
answered on 04 Feb 2010, 05:28 PM
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?
0
Dimo
Telerik team
answered on 05 Feb 2010, 08:11 AM
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.
0
newbie
Top achievements
Rank 1
answered on 08 Feb 2010, 09:22 PM
I am sorry if I am not getting this right.

So where should I call the function executeAfterAJAX() ?
0
Dimo
Telerik team
answered on 11 Feb 2010, 07:24 AM
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.
0
Howard
Top achievements
Rank 1
answered on 15 Jan 2015, 10:22 PM
WHY DON'T THESE EXPENSIVE CONTROLS WORK WITH THE .NET VALIDATORS?
0
Maria Ilieva
Telerik team
answered on 19 Jan 2015, 09:05 AM
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.

 
Tags
Calendar
Asked by
newbie
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
newbie
Top achievements
Rank 1
Dimo
Telerik team
Howard
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or