0

I'm trying to write a component to create a group button using bootstrap in ASP.Net-MVC C#.

I've successfully write it, but I have a little problem. In form validation, I need to check if at least one a element in my button group was selected. How can I add data-val or required to my button group?

Here is an example of this component:

<div class="btn-group" role="group" id="User_Sex">

        <label class="btn btn-primary">
            <input name="User.Sex" value="Male" class="d-none" type="radio">
            <span>Male</span>
        </label>

        <label class="btn btn-primary">
            <input name="User.Sex" value="Female" class="d-none" type="radio">
            <span>Female</span>
        </label>

</div>

Do I need an input or select to do it?

ali
  • 330
  • 2
  • 13

0 Answers0