This question is locked. New answers and comments are not allowed.
Hi,
I want to set the minimum value of Telerik Date Picker using javascript.. I tried it with
but it is not working...
Waiting for the replies..
Thankin you in Anticipation...
I want to set the minimum value of Telerik Date Picker using javascript.. I tried it with
$('#todate').datetime(tDatePicker).minDate = $myValue
Waiting for the replies..
Thankin you in Anticipation...
6 Answers, 1 is accepted
0

Peter
Top achievements
Rank 1
answered on 15 Oct 2010, 09:50 AM
Hi,
In order to set min/max date, you need to use Telerik's datetime object!
Here is a code snippet showing how to achieve this:
Regards,
Peter
In order to set min/max date, you need to use Telerik's datetime object!
Here is a code snippet showing how to achieve this:
$(
'#todate'
).datetime(tDatePicker).minDate = $.telerik.datetime(2000,10,10);
Regards,
Peter
0
Dhaval
Top achievements
Rank 2
answered on 15 Oct 2010, 10:32 AM
Hi Peter,
Thanx for your reply.. I tried the way you suggested but it is not working here is the code that i tried:
Thanx for your reply.. I tried the way you suggested but it is not working here is the code that i tried:
$('#enddate').datetime(tDatePicker).minDate = $.telerik.datetime(2000,10,10);
0

Peter
Top achievements
Rank 1
answered on 15 Oct 2010, 11:45 AM
Hi,
I was misled from your first code snippet. You do not get correctly the DatePicker client object. It will be good to look at the online documentation.
Here is the correct code excerpt:
Regards,
Peter
I was misled from your first code snippet. You do not get correctly the DatePicker client object. It will be good to look at the online documentation.
Here is the correct code excerpt:
$(
'#todate'
).data(
'tDatePicker'
).minDate = $.telerik.datetime(2000,10,10);
Regards,
Peter
0
Dhaval
Top achievements
Rank 2
answered on 16 Oct 2010, 12:48 PM
Hi,
I am getting one strange problem, I think my syntax is also correct and there is no mistake in my code here is my code snippet:
what problem i am facing is it is giving me the error like
I am getting one strange problem, I think my syntax is also correct and there is no mistake in my code here is my code snippet:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<
DateTime
?>" %>
<% var controlName = ViewData.TemplateInfo.GetFullHtmlFieldName(""); %>
<%= Html.Telerik().DatePicker()
.Name(controlName)
.HtmlAttributes(new { id = ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty) + DateTime.Now.Millisecond.ToString() })
.Value(Model > DateTime.MinValue ? Model : DateTime.Today)
.Format("MM/dd/yyyy").ClientEvents(ce => ce.OnChange("OnChange"))%>
<
script
type
=
"text/javascript"
>
function getDateInFormat(myValue) {
return $.telerik.formatString("{0:yyyy/MM/dd}", myValue);
}
function OnChange(e) {
var user = {};
var cntrl = '<%= controlName%>'
var myController = $('#<%= controlName%>').data('tDatePicker');
if (cntrl == "dateofbirth")
{
var $myValue = getDateInFormat(e.date);
var fillListUrl = '<%= Url.Action("_GetClient", "SearchCustomer")%>';
$.post(fillListUrl, { criteria: $myValue, controllerName: ('<%= controlName%>') }, function (data) {
if (data.result) {
$('#SearchCustomer').data('tGrid').rebind({ code: data.client.code }); $("div").show("slow");
}
else {
alert('Employee Not Found');
}
}, 'json');
}
if (cntrl == '_end') {
var $myValue = getDateInFormat(e.date);
alert(myController.value());
$('#_end').data('tDatePicker').minDate($myValue
);
// = $.telerik.datetime(2000, 10, 10);
//({ format: 'dd/MM/yyyy', minDate: new $.telerik.datetime($myValue) });
}
}
</
script
>
myController is undefined, so i m not gettin myController.value().. And when i am setting the minimum value for _end using:
$('#_end').data('tDatePicker').minDate($myValue
); it is also not working giving the same undefined javascript error..
Waiting for the replies..
Thanking you in Anticipation..
Regards,
Dhaval
0

Uma
Top achievements
Rank 1
answered on 28 Oct 2010, 10:25 PM
Hi Dhaval,
I came across the same situation today,but by luck i got the solution for this.
Hope this helps..
Regards,
Uma
I came across the same situation today,but by luck i got the solution for this.
function startDateChange(e) {
var datePicker = $("#EndDate").data("tDatePicker");
datePicker.minDate.value = e.date; //here datetime value comes
}
Hope this helps..
Regards,
Uma
0

Mark
Top achievements
Rank 1
answered on 12 Mar 2012, 05:05 PM
None of the other replies worked for me, but this did:
function
startDateChanged(e) {
var
datePicker = $(
"#Preferences_EndDate"
).data(
"tDatePicker"
);
var
startDate =
new
Date(e.date);
var
minDate =
new
Date(startDate);
minDate.setDate(startDate.getDate() + 4);
datePicker.min(minDate);
}