I am new to mvc3 and razor engine and I would like it so at least one checkbox is checked for the submit button to fire.
<div class="editor-field">
@Html.Label("item1")
@Html.CheckBoxFor(Model => Model.item1)
@Html.Label("item2")
@Html.CheckBoxFor(Model => Model.item2)
@Html.Label("item3")
@Html.CheckBoxFor(Model => Model.item3)
</div>
<p>
<input type="submit" value="Create" />
</p>
I know that I would need some kind of label to render text if 0 checkboxes are selected and that each checkbox needs an id so I can look at their values but is there anything in mvc3 razor to make this simpler? Thanks
One way of many would be to
and in your javascript (you might have more here but keeping it simple)