0

In View

    <td class="SrcFld">
        <div>
         @Html.TextBox("BeginDate", Model.BeginDate)&nbsp;   
        @Html.RequiredFieldFor(model => model.BeginDate)
        @Html.ValidationMessageFor(model => model.BeginDate)
        To &nbsp; @Html.TextBox("EndDate", Model.EndDate)
        @Html.RequiredFieldFor(model => model.EndDate)
        @Html.ValidationMessageFor(model => model.EndDate)
        </div>
    </td>

In Model

>

 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; }
    }

My Question, validation of end date and begin date required fields are working.but Greater Than validation is not working.actually i am using "foolproof" validations.please help me out.Thanks!!

Rafay
  • 30,950
  • 5
  • 68
  • 101
user1169594
  • 63
  • 3
  • 10

2 Answers2

0

The topic shows someone who created their own validaton attribute as well as the client rules for the validate plugin:

MVC custom validation: compare two dates

Community
  • 1
  • 1
Nick Bork
  • 4,831
  • 1
  • 24
  • 25
  • Did you follow the guid for "foolproof" @ http://foolproof.codeplex.com/? Did you include all of the validation scripts needed? Client Validation won't occure without the scripts. The only difference between their sample and your code is that their code doesn't use a nullable DateTime. – Nick Bork Jan 26 '12 at 22:05
0

The answer to

Perform client side validation for custom attribute

shows how to get custom date validation working.

In a similar situation I used remote validation to check the minimum difference between the two dates, the minimum difference depended on the start date..

Community
  • 1
  • 1
PhilW
  • 410
  • 4
  • 11