http://thewayofcode.wordpress.com/2012/01/18/custom-unobtrusive-jquery-validation-with-data-annotations-in-mvc-3/MVC3日期验证
我试图从上面的链接工作,但不能得到它正确的示例。我不确定我做错了什么?
我复制的模型验证
[DataType(DataType.Date)]
[DisplayName("Start Date of Construction")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? StartDate { get; set; }
[DataType(DataType.Date)]
[DisplayNameAttribute("End Date of Construction")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
[DateGreaterThan("StartDate", "Estimated end date of construction must be greater than the start date of the construction")]
public DateTime? EndDateOf { get; set; }
其次DateGreaterThan代码。
在查看@Html.EditorFor(model => model.StartDate)
@Html.EditorFor(model => model.EndDate)
@Html.ValidationMessageFor(model => model.StartDate)
@Html.ValidationMessageFor(model => model.EndDate)
但没有火灾的按钮点击
,如果有人能提供一些线索light.It将是非常有益的,甚至这样做是appreciated.Similarly试图获得的任何其他不同的方式在下拉列表中选择一个值并在文本框中输入值时,从Model进行验证工作。
我们可以看到您的控制器代码在哪里发布表单数据? – Tommy 2012-08-08 21:49:19
您正在关注的示例的源代码可以从[here](https://github.com/vgheri/DateCustomValidationExample)下载。下载它,并与您尝试过的内容进行比较,这样您就可以更快地找到解决方案,更重要的是,您将很乐意自己找出问题所在。相信我 ! – Yasser 2012-08-09 05:25:39