Data Annotate multiple CheckboxFor columns as required in MVC

爷,独闯天下 提交于 2019-12-24 16:35:38

问题


I am having two Kendo checkboxes and I want to validate it as checking atleast one of them is required.

 <h4>Choose your favorite dance form</h4>
    <div class="form-group">

        <div class="col-md-6">
            @(Html.Kendo().CheckBoxFor(e => e.Salsa)
    .Name("Salsa")
    .Label("Salsa"))
            <br />
            @(Html.Kendo().CheckBoxFor(e => e.Latin)
    .Name("Latin")
    .Label("Latin"))
        </div>
    </div>

Below is how my properties are defined in my Model:

        public bool Salsa { get; set; }

        public bool Latin { get; set; }

How can I data annotate them, so that atleast one is required validation takes place.

Thanks!

来源:https://stackoverflow.com/questions/36925206/data-annotate-multiple-checkboxfor-columns-as-required-in-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!