I have two date field in my Page fromDate and ToDate. ToDate should be greater than FromDate. I need to validate it in client side. I'm using Foolprof for clied side validation
reference added
using Foolproof;
Script added
<script src="~/Scripts/mvcfoolproof.unobtrusive.min.js"></script> <script src="~/Scripts/MvcFoolproofJQueryValidation.min.js"></script> <script src="~/Scripts/MvcFoolproofValidation.min.js"></script>
My model contains below code
[Required(ErrorMessage = "The start date is required")] public DateTime StartDate { get; set; } [Required(ErrorMessage = "The end date is required")] [GreaterThan("StartDate")] public DateTime EndDate { get; set; }
and in controller done using default scaffolding.
my .cshtml contain below code for Dates
<div class="form-group">
@Html.LabelFor(model => model.StartDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.StartDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.StartDate, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EndDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.EndDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.EndDate, "", new { @class = "text-danger" })
</div>
</div>
Now my validation is not working in Client side but working in server side after clicking submit button.
Please provide me some guidence..
Thank you.