Badly formatted user input

3 posts, 1 answers
  1. Henrik
    Henrik avatar
    11 posts
    Member since:
    Nov 2015

    Posted 26 May Link to this post

    Hi,

    I have a DatePicker that displays the date nicely in the correct format i.e. "2016-05-26" for May 26, 2016.

     

    I would like to handle badly formatted user input, like "160531" which is an allowed way to enter a date in our organisation. I want to take this date and format it correctly with some JS code. The problem is that when I input a date like this I can't get it from the datepicker in my javascript code.

    JS Code:

           var date1 = kendo.toString($("#RelevantDate").data("kendoDatePicker").value(), 'd');
            var date2 = $("#RelevantDate").data("kendoDatePicker").value();

    both the date1 and the date2 variable are null if I have a date like "160531". With a nicely formatted date everything works.

     

    Is there any way to get a badly formatted date out of the datepicker? I want the users to be able to select the date in the picker and to enter the date manually so changing to a textbox input is not an option.

     

    Best regards,

    Henrik
     

  2. Answer
    Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 26 May Link to this post

    Hi,

    You can refer to the sample dojo example below which shows how to parse the input value to the desired format:
    http://dojo.telerik.com/OCeQI/3

    It should help you achieve your goal.

    Regards,
    Pavlina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Henrik
    Henrik avatar
    11 posts
    Member since:
    Nov 2015

    Posted 27 May Link to this post

    Thanks for the prompt reply,

     

    Took me a little trial-and-error, but I got it to work as I wanted. Thanks!

     

    Henrik

Back to Top