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

RadMonthYearPicker - Not allow future dates

3 Answers 401 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 24 Jan 2015, 02:39 PM
I am trying to use a control which will only allow users to select the Month and Year. BUT, I need to also not allow them to choose future dates based on todays date. I  am working in vb.net and had found this example, but cannot get it to work in vb. http://birenpanigrahi.blogspot.com/2013/11/radmonthyearpicker-validation-restrict.html

Any help would be greatly appreciated. I have also tried to use a RadDatePicker which I can restrict the future date based on todays date as the date changes, but I do not want the days to display for selection. If there is a way to only allow RadDatePicker to show Month and Year in the popup instead of Day, Months and Years, I would take that as well.

Thank you.

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 26 Jan 2015, 09:51 AM
Hi Chris,

The range validator should have specific format ("yyyy-MM-dd-hh-mm-ss"), that is culture independent. This way it will work the same in out end user computers, regardless of their local settings.
Check this page of our documentation for further details and examples:
http://www.telerik.com/help/aspnet-ajax/input-validation.html

Regards,
Vasil
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.

 
0
Chris
Top achievements
Rank 1
answered on 26 Jan 2015, 05:36 PM
Hi Vasil,

I have looked at what you have suggested. I have even tried this previously but I receive the following Error:
Type 'Telerik.Web.UI.RadMonthYearPicker' does not have a public property named 'RangeValidator'.

So it seems this cannot work. Also, I do not want a specific date in. I would like to just restrict the radmonthYearPicker from allowing any future dates based on the current date. So, as each day comes and goes, the picker allows for that. (Obviously it would only happen by month, so once Feb1 arrives, then user can select Feb and 2015 from the picker.)

I did find this code which helps, but only on RadDatePicker control.

(see below code)

 My problem with that picker, is I cant get it to display only the Month / Year. It displays the days as well. I had found a post on here from another developer which stated they had gotten the RadDatePicker to only show Month and Year, but I do not know how they exactly did that? If it is doable, I would be interested in knowing how.

Thank you again.

var date = new Date();

function RadDatePicker_SetMaxDateToCurrentDate(sender, args)

{

var arr = new Array(date.getFullYear(), date.getMonth() + 1, date.getDate());

sender.set_rangeMaxDate(arr);

}

0
Vasil
Telerik team
answered on 27 Jan 2015, 07:56 AM
Hello Chris,

The error that you get indicates that you are trying to place the Validator inside the markup of the picker. It should be placed after/before the DatePicker inside it. Here is an example:

<telerik:RadDatePicker ID="RadDatePicker1" runat="server" DateFormat="d" MinDate="01/01/1990"
    MaxDate="01/01/3000">
</telerik:RadDatePicker>
 
<asp:RangeValidator ID="DateInputRangeValidator" runat="server" ControlToValidate="RadDatePicker1"
    Text="Choose a date between 5th of January 2005 and 1st of September 2005"
    MaximumValue="2005-09-01-00-00-00" MinimumValue="2005-01-05-00-00-00">

For the MonthYear picker you will need to use CustomValidator or CompareValidator:
http://demos.telerik.com/aspnet-ajax/calendar/examples/monthyearpicker/validation/defaultcs.aspx

Regards,
Vasil
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
Chris
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Chris
Top achievements
Rank 1
Share this question
or