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

Allow custom date format

2 Answers 58 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
jgig
Top achievements
Rank 1
jgig asked on 05 Dec 2008, 05:18 PM
I edited and deleted most of my original post because the date format I wanted to support I just found out you already do( ex: "24Jan"). I recently updated the controls so this must be fairly new.
 
I  just need to - if the month is before current month increment the year now. Example if they enter 12Oct I want it to be year 09 and not 08. Always has to be with in the future.

love these controls!

2 Answers, 1 is accepted

Sort by
0
jgig
Top achievements
Rank 1
answered on 05 Dec 2008, 09:49 PM
SO I have my function working the way I want now. Just want to do it a little better. I dont like the way I had to find the objDatePicker. 

<

 

DateInput ClientEvents-OnBlur="CorrectDateYear"></DateInput>
Because I have the onBlur of the DateInput I didnt know how to get the Parent DatePicker object and I am in a Repeater so I cant just use the <%= DatePicker.ClientID %>. 

Is there a way to use something like this? I noticed some objects allow this.
var objDatePicker = sender.get_parent();

function CorrectDateYear(sender, eventArgs)  
{  
    if (!sender.isEmpty())  
    {  
        var dtToday = new Date();//Todays Date  
        var strDateInputID = sender.get_id();//Sender is the DateInput  
        var strDatePickerID = strDateInputID.replace("_dateInput""");//Remove _dateInput and that is the picker ID  
        var objDatePicker = $find(strDatePickerID);  
        if(objDatePicker != null){  
            var dtUserInput = objDatePicker.get_selectedDate();//Users date they entered  
            if(dtToday > dtUserInput)//No dates allowed in the past  
            {  
                dtUserInput.setYear(dtToday.getFullYear() + 1);//use todays year that way if they enter a date 2 years old it will still be in the furure  
                objDatePicker.set_selectedDate(dtUserInput);  
            }  
        }  
    }  
0
Daniel
Telerik team
answered on 08 Dec 2008, 09:06 AM
Hello Jeremy,

Please test the following code-snippet:
var objDatePicker = sender.Owner; 

Let me know if I missed something.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Calendar
Asked by
jgig
Top achievements
Rank 1
Answers by
jgig
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or