1

I've found the model annotations very useful for the validation in MVC but can't seem to get it working for a checkbox. I am using MVC 3 with razor and c#.

Thanks

2
  • What are you trying to validate? That it is checked? Are you suggesting that a false value for your property is not a valid value? Is this a checkbox for a user to "check" in order to go to a next step like accepting a terms of service? Commented Apr 25, 2012 at 15:13
  • 1
    See: stackoverflow.com/questions/2766952/… Commented Apr 25, 2012 at 15:21

1 Answer 1

0

Last time I heard this question, the customer wanted to verify whether the question had been answered or not. This is not possible with a checkbox, and can only be done by using a pair of radio buttons for yes and no and defaulting both to unchecked. Then when submitted, if neither button is checked, validation fails.

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

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.