Site now allows promotion codes. If the promotion brings the payment amount to 0 the client doesnt want to require credit card information to be entered. Currently the ViewModels have required on the CC information. Now need to make it conditional. Any way to do this through attributes?
1 Answer
What you basically want is a [RequiredIf] data annotation attribute, unfortunately this is not built into MVC4, but the good news is that there is a nuget package available. The alternative is of course to write your own server and jquery unobtrusive validation method yourself which isn't too hard.
Have a look at RequiredIf on https://foolproof.codeplex.com/ and to install the package, simply use the NuGet package console and install-package foolproof, or search for foolproof in the package manager.
1 Comment
Jack
But foolproof seems to not working on MVC4? Any idea?