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")]
    [Required()]
    public DateTime? BirthDate { get; set; }


    And in a partial view I have:

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

    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
    Admin
    Daniel avatar
    2117 posts

    Posted 21 Mar 2014 Link to this post

    Hello,

    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.

    Regards,
    Daniel
    Telerik
     

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top