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

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

2 Answers 1566 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 13 Apr 2016, 10:17 AM

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 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 2
answered on 13 Apr 2016, 10:22 AM
I'm using kendo ui 2015.3.1111 jquery-1.11.1
0
Dimiter Topalov
Telerik team
answered on 15 Apr 2016, 10:19 AM
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!
Tags
Date/Time Pickers
Asked by
John
Top achievements
Rank 2
Answers by
John
Top achievements
Rank 2
Dimiter Topalov
Telerik team
Share this question
or