<td class="SrcFld">
<div>
@Html.TextBox("BeginDate", Model.BeginDate)
@Html.RequiredFieldFor(model => model.BeginDate)
@Html.ValidationMessageFor(model => model.BeginDate)
To @Html.TextBox("EndDate", Model.EndDate)
@Html.RequiredFieldFor(model => model.EndDate)
@Html.ValidationMessageFor(model => model.EndDate)
</div>
</td>
>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Foolproof;
namespace HPAI.HPA.Web.Models
{
public class UnEmploymentInputs : UserInputs
{
[Required]
public DateTime? BeginDate { get; set; }
[Required]
[GreaterThan("BeginDate", ErrorMessage = "End Date Should be Greater Than Begin Date.")]
public DateTime? EndDate { get; set; }
public decimal? NonEscrowTax { get; set; }
public decimal? NonEscrowInsurance { get; set; }
public bool? IsExtension { get; set; }
public bool? IsIncomeCircumstance { get; set; }
}
モデル
でASP.NET MVC3で日付の検証を開始している私の質問の 検証終了日と開始日必要なフィールドはworking.but以上の検証は動作していません。実際に私は "簡単な" validations.pleaseを使用して私を助けるout.Thanks!
やあ、実際に私は誰にでもvalidatiorsを使用しました。しかし、それは酔いどれません....! – user1169594
"foolproof" @ http://foolproof.codeplex.com/のguidに従っていますか?必要な検証スクリプトをすべて含めましたか?クライアントの検証はスクリプトなしでは発生しません。サンプルとコードの唯一の違いは、コードでnull可能なDateTimeが使用されていないことです。 –