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