I think this is a pretty simple task, but I can't for the life of me get it working.
Environment - MVC3, FluentValidation, StructureMap.
I have a ViewModel (RegisterViewModel) that has the following attributes { Email, IsBusiness, BusinessContact }. Email is required a开发者_JAVA百科lways, BusinessContact is required if the IsBusiness checkbox is checked.
I was trying to perform the BusinessContact required check client side, but can't for the life of me figure out the right way to do this.
Suggestions?
You will have to roll your own client side validation to enforce the constraint your looking for. Phil Haack has a great post on how to do this http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-validation.aspx
Otherwise you could just enforce the constraint server side and add an error to the ModalState and reload the view.
精彩评论