0

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

2 Answers 2

2

You may take a look at MVC Foolproof Validation which provides additional attributes or simply write your own custom attribute:

[Required]
public DateTime? BeginDate { get; set; }

[Required]
[GreaterThan("BeginDate")]
public DateTime? EndDate { get; set; }

Another possibility is to use FluentValidation.NET which integrates really nicely with ASP.NET MVC.

Sign up to request clarification or add additional context in comments.

Comments

0

if you are interested in writing your own custom validation with both server and client side validation using DataAnnotations and jQuery, I wrote a blog article about this

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.