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

Date : Auto-formatting

1 Answer 33 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Aarsh
Top achievements
Rank 1
Aarsh asked on 16 Apr 2013, 01:10 PM
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 ?

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 19 Apr 2013, 07:51 AM
Hi,

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" />
    </telerik:RadDateInput>
    <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("/", "");
                args.set_newValue(n);
            }
        }
    </script>


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.
Tags
Calendar
Asked by
Aarsh
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or