Tuesday, 13 May 2014

telerik:RadDatePicker OnValueChanging

<script type="text/javascript">
        function ValueChanging(sender, args)
        {
            if (sender.get_dateFormat() == "MM/yyyy")
            {
                var selectedDay = sender.get_owner().get_calendar().get_selectedDates()[0][2];
                var value = args.get_newValue();
                var monthPlace = sender.get_dateFormatInfo().DateSlots["Month"];
                if (monthPlace == 1)
                {
                    args.set_newValue(selectedDay + "/" + value);
                }
                else
                {
                    var monthAndYear = value.split("/");
                    args.set_newValue(monthAndYear[0] + "/" + selectedDay + "/" + monthAndYear[1]);
                }
            }
        }
    </script>
 
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <DateInput ID="DateInput1" DateFormat="MM/yyyy" runat="server"
            ClientEvents-OnValueChanging="ValueChanging" />
    </telerik:RadDatePicker>