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

Validation Error Styling When Date is Required

1 Answer 35 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 19 Mar 2014, 06:29 PM
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.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Mar 2014, 03:53 PM
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.

 
Tags
Date/Time Pickers
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or