I have 2 columns to enter in UI. How to give Regular Expression based on those 2 columns for Error Message and Condition in ASP.NET MVC3?
The Condition which is in jQuery, I am migrating to MVC3 Side:
if (((new Date(Date.parse($("#hupUnempBftsEndDate").val()) - Date.parse($("#hupUnempBftsBeginDate").val()))) / 86400000) < 0) {
validationSummary = validationSummary + "! End Date of Unemployment Benefits can't be prior to Effective Date of Unemployment Benefits. \n";
.NET code:
public DateTime? BeginDate { get; set; }
public DateTime? EndDate { get; set; }
You may take a look at MVC Foolproof Validation which provides additional attributes or simply write your own custom attribute:
Another possibility is to use FluentValidation.NET which integrates really nicely with ASP.NET MVC.