0

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 1

5

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.

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

1 Comment

But foolproof seems to not working on MVC4? Any idea?

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.