3

我的模型中有一個名爲StartDate的屬性。我已經使用timepicker插件來自herejquery.ui插件。它工作正常,但問題是我得到驗證錯誤消息。我如何更改驗證,以便通過日期時間。jQuery時間選擇器和MVC驗證 - 該字段必須是日期

的模型是:

public class DateTimePickerTest : EntityBase 
{ 
    [DataType(DataType.DateTime)] 
    [DisplayName("Start Date")] 
    public DateTime StartDate { get; set; } 
    [DataType(DataType.DateTime)] 
    [DisplayName("End Date")] 
    public DateTime EndDate { get; set; } 
} 

Following is the error message

我主要是以下幾個方向給出here on MSDN by Rick Anderson

+0

也請發表您的模型和註釋使用的是在這裏。 – Yasser

+0

@亞瑟我已經添加了模型。如果你需要別的東西,請讓我知道。 – TheVillageIdiot

回答

4

this answer保存。

我已經使用DisplayFormat屬性與ApplyFormatInEditMode屬性設置爲true

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.mm.yy}")] 
+0

不適用於Safari – Liladhar

相關問題