Validation Error Styling When Date is Required

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    16 posts
    Member since:
    Feb 2013

    Posted 19 Mar 2014 Link to this post

    I have a nullable DateTime in a model and is set to required:

    [Display(Name = "Birth Date")]
    public DateTime? BirthDate { get; set; }

    And in a partial view I have:

    <div class="tableRow">
      <span class="tableCellLabelIndent">
        @Html.LabelFor(m => m.BirthDate)
      <span class="tableCellInputWide">
        @Html.EditorFor(m => m.BirthDate, "Date")
        @Html.ValidationMessageFor(m => m.BirthDate)

    When the date is left blank, I get the validation error message, but I don't get the red outline styling that is typical with validation errors. A regular text box with the "k-textbox" styling works OK.

  2. Daniel
    Daniel avatar
    2177 posts

    Posted 21 Mar 2014 Link to this post


    The red border will not be visible with the datepicker because the input is wrapped in other elements. It is possible to show border also for the datepicker by copying the classes from the input to the wrapper as demonstrated in the "kendo-input-widgets-validation" sample project from this repository.


    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Back to Top