How to validate check box by using Microsoft MVC, Data Annotations Validation

4/1/2014
If you want to validate your checkbox when click button.(Just sample)

  Must be check.

You might have other way to do this, but so far my solution for this is checkbox'll be MVC's custom validation. MVC's custom validation means, you have to add your own validation on both server side and client side.

So, if you want to add custom validation, first you need to do is add server side validation code.

Add your custom validation attribute code

Add custom attribute to your Model's property, which display to UI

The razor view example

That's all about to imprement server side custom validation for checkbox.

You could go to following page to check demo.

DEMO

If you're first add mvc validation,you might need to add some setting to your file. You could reference following blog to check it out.

MVC Validation Setting

I'll add client custom validation in the future.