Hello,
If I enter "30/22/09" into the first control in this demo, it gets updated to be "9/30/2022" rather than displaying an error indicating the date is invalid. If I enter "9", it gets changed to "8/9/2009". Is there a way to disable this and just show this as an invalid date?
Thanks
-marcos
If I enter "30/22/09" into the first control in this demo, it gets updated to be "9/30/2022" rather than displaying an error indicating the date is invalid. If I enter "9", it gets changed to "8/9/2009". Is there a way to disable this and just show this as an invalid date?
Thanks
-marcos
4 Answers, 1 is accepted
0
Hello TriZetto,
You can cancel the ValueChanging event when the value is not considered as a valid date:
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can cancel the ValueChanging event when the value is not considered as a valid date:
<script type="text/javascript"> |
function valueChanging(sender, args) |
{ |
if (new Date(args.get_newValue()) == "NaN") |
args.set_cancel(true); |
} |
</script> |
<telerik:RadDatePicker ID="RadDatePicker1" runat="server"> |
<DateInput> |
<ClientEvents OnValueChanging="valueChanging" /> |
</DateInput> |
</telerik:RadDatePicker> |
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

TriZetto
Top achievements
Rank 1
answered on 19 Aug 2009, 02:27 PM
Thank you for your reply, but this does not change the behavior of the control. It still changes
"30/22/09" to "9/30/2022"
"9" to "8/9/2009"
"a4" to "9/30/2022"
To me the input is all invalid given the current culture, but I do not see a way of indicating this to the user. In you suggested solution,
new Date(args.get_newValue()) for any of these answers results in a valid date (today's date).
I suppose in this event handler I can try to match the string with a date regular expression. But I am wondering if there is an alternative.
Thanks
-marcos
"30/22/09" to "9/30/2022"
"9" to "8/9/2009"
"a4" to "9/30/2022"
To me the input is all invalid given the current culture, but I do not see a way of indicating this to the user. In you suggested solution,
new Date(args.get_newValue()) for any of these answers results in a valid date (today's date).
I suppose in this event handler I can try to match the string with a date regular expression. But I am wondering if there is an alternative.
Thanks
-marcos
0
Accepted
Hello TriZetto,
You can handle such data by overriding the built-in date parser engine:
I hope this helps.
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can handle such data by overriding the built-in date parser engine:
<script type="text/javascript"> |
Telerik.Web.UI.RadDateInput.prototype.parseDate = function(value, baseDate) |
{ |
if (new Date(value) != "NaN") |
return value; |
} |
</script> |
<telerik:RadDatePicker ID="RadDatePicker1" runat="server"> |
<DateInput> |
<ClientEvents /> |
</DateInput> |
</telerik:RadDatePicker> |
I hope this helps.
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

sara r
Top achievements
Rank 1
answered on 10 Mar 2010, 01:55 PM
hi
i have a similar issue. but adding this
causes a js error.
It doesnt solve the issue.
In the textbox if i enter 1/5/19 it automatically fills 01/05/2019. when i clear that and tried to enter some other invald date, it gives me the previously populated date ie, 01/05/2019.
Please help
i have a similar issue. but adding this
<script type="text/javascript"> |
Telerik.Web.UI.RadDateInput.prototype.parseDate = function(value, baseDate) |
{ |
if (new Date(value) != "NaN") |
return value; |
} |
</script> |
It doesnt solve the issue.
In the textbox if i enter 1/5/19 it automatically fills 01/05/2019. when i clear that and tried to enter some other invald date, it gives me the previously populated date ie, 01/05/2019.
Please help