RadDateInput Parsing for Month-Year Input

2 posts, 0 answers
  1. Charles
    Charles avatar
    33 posts
    Member since:
    Feb 2013

    Posted 11 Mar 2014 Link to this post

    We are using the RadDateInput for drivers license expiration date. Some users want to enter only the month and year such as 02/2014 but the control parses this to 3/2/2014 rather than 2/1/2014. Is there a workaround for this behavior?


  2. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 11 Mar 2014 in reply to Charles Link to this post

    When you enter two numbers in the RadDateInput control (one of which is the year), it always assumes that one number is the year and the other one is the day (and takes the current month).You can try with the below implementation to resolve this issue

    HTML Mark up:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="EmptyWebApp.WebForm2" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <script type="text/javascript">
            function DateInput1ValueChanging(sender, args) {
                var newv = args.get_newValue();
                var newvArray = newv.split("/");
                if (newvArray.length == 2) {
                    // if the date format is dd/MM/yyyy, the 01 string should be appended in the beginning, not in the middle
                    args.set_newValue(newvArray[0] + "/01/" + newvArray[1]);
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            <telerik:RadDateInput ID="RadDateInput1" runat="server" DateFormat="MM/dd/yyyy" DisplayDateFormat="MM/dd/yyyy">
                <ClientEvents OnValueChanging="DateInput1ValueChanging" />

    protected void Button1_Click(object sender, EventArgs e)
               //Get the Value
               string value = RadDateInput1.Text;

    Source URL
Back to Top