Date : Auto-formatting

2 posts, 0 answers
  1. Aarsh
    Aarsh avatar
    192 posts
    Member since:
    Jun 2012

    Posted 16 Apr 2013 Link to this post

    Our QA posted this : Date formatting:  When ‘04162013’ is entered, the field will auto-format the entry to reflect ‘04/16/2013’.  If ‘0416/2013’ or ‘04/162013’ is entered….the field flags the entry as an error and will not auto-format

    Is there anything I can do using JavaScript and such ?
  2. Angel Petrov
    Angel Petrov avatar
    1094 posts

    Posted 19 Apr 2013 Link to this post


    You can intercept the client-side OnValueChanging event and correct the value. An example of this is demonstrated below:
    <telerik:RadDateInput runat="server">
            <ClientEvents OnValueChanging="ValueChanging" />
        <script type="text/javascript">
            function ValueChanging(sender, args)
                var newValue = args.get_newValue();
                if (newValue.indexOf("/") > -1)
                    var newValue = args.get_newValue();
                    var n = newValue.replace("/", "");

    All the best,
    Angel Petrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top