How to validate two properties with ASP.NET MVC 2

Posted by CodeMonkey on Stack Overflow See other posts from Stack Overflow or by CodeMonkey
Published on 2010-03-15T20:21:48Z Indexed on 2010/03/15 21:19 UTC
Read the original article Hit count: 326

Hey folks :-)

I'm just getting started with ASP.NET MVC 2, and playing around with Validation.

Let's say I have 2 properties:

  • Password1
  • Password2

And I want to require that they are both filled in, and require that both are the same before the model is valid.

I have a simple class called "NewUser".

How would I implement that? I've read about ValidationAttribute, and understand that. But I don't see how I would use that to implement a validation that compares two or more properties against eathother.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-2