Kendo DateTimePicker validation erro must be a date (but it is)

3 posts, 0 answers
  1. John
    John avatar
    2 posts
    Member since:
    Nov 2014

    Posted 13 Apr Link to this post

    I need to use a specific date time format dd-MMM-yyyy HH:mm. I am getting a validation error "The field Start Date Time must be a date." when using "13-Apr-2016 11:12" which should be valid. 

    Razor

      @using (Html.BeginForm())
                {

                    @Html.HiddenFor(m => m.PersonId)

     @(Html.Kendo().DateTimePicker()

                              .Name("StartDate")
                              .Value(Model.StartDate)
                              .HtmlAttributes(new { placeholder = "dd-MMM-yyyy HH:mm" })
                              .Format("dd-MMM-yyyy HH:mm")
                              .ParseFormats(new[] { "dd-MMM-yyyy HH:mm" })
                              .Culture("en-GB")
                              .TimeFormat("HH:mm"))

      <input type="submit" value="OK" name="submitButton" />

    }

    Model

    public class ConfirmPGDViewModel

    {

            [Required]
            public long PersonId { get; set; }

            [Display(Name = "Start Date Time")]
            [Required]
            public DateTime? StartDate { get; set; }

    }

    Controller

     public ActionResult ConfirmPGD(long personId)
            {
                         var viewModel = new ConfirmPGDViewModel
                    {         

                        PersonId = personId,                    

                        StartDate = DateTime.Now,                    
                    };

    return this.View(viewModel);

    }

  2. John
    John avatar
    2 posts
    Member since:
    Nov 2014

    Posted 13 Apr in reply to John Link to this post

    I'm using kendo ui 2015.3.1111 jquery-1.11.1
  3. Kendo UI is VS 2017 Ready
  4. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    347 posts

    Posted 15 Apr Link to this post

    Hi John,

    Please check out the following section of our documentation and apply the necessary adjustments to your implementation:

    http://docs.telerik.com/kendo-ui/aspnet-mvc/troubleshoot/troubleshooting-validation#globalized-dates-and-numbers-are-not-recognized-as-valid-when-using-the-validator

    Let me know if you need further assistance.

    Regards,
    Dimiter Topalov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top