Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:43:49+00:00 2026-06-17T13:43:49+00:00

So I have this Model: public int ID { get; set; } [Required(ErrorMessage =

  • 0

So I have this Model:

    public int ID { get; set; }
    [Required(ErrorMessage = "A Name is required")]
    public string Name { get; set; }
    public bool GreenCircle { get; set; }
    public bool BlueSquare { get; set; }
    public bool BlackDiamond { get; set; }
    public bool TerrainPark { get; set; }

Currently the View I have that allows a user to create a profile sets up Checkboxes for the bool properties listed here.

I am looking for a way to set up JQuery Validation that will require that one and only one of these bool properties is set to true so I’m thinking I should be using RadioButtons but I’m not quite sure how I can group those when they get set up in a View or how I can perform that type of validation.

Any ideas? I’m here to learn so please point me in the right direction for research if you must; thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:43:50+00:00Added an answer on June 17, 2026 at 1:43 pm

    Use an enum. For example:

    public enum MyEnum
    {
        GreenCircle,
        BlueSquare,
        BlackDiamond,
        TerrainPark
    }
    

    Then use it in your model instead of four different boolean properties.

    public class MyModel
    {
        public MyEnum MyOption { get; set; }
    }
    

    Then generate radiobuttons in your view.

    @using (Html.BeginForm())
    {
        @Html.RadioButtonFor(m => m.MyOption, (int)MyEnum.BlackDiamond);
        <span>Black Diamond</span><br />
        @Html.RadioButtonFor(m => m.MyOption, (int)MyEnum.BlueSquare, 
            new { @checked = "true" });
        <span>Blue Square</span><br />
        @Html.RadioButtonFor(m => m.MyOption, (int)MyEnum.GreenCircle);
        <span>Green Circle</span><br />
        @Html.RadioButtonFor(m => m.MyOption, (int)MyEnum.TerrainPark);
        <span>Terrain Park</span><br />
    }
    

    Remark: Maybe you can implement an HTML helper to generate the radio button markup for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Model public class SalesModelView { [Key] public int SaleId { get;
My Model: public class EntryModel { [Required] public string Date { get; set; }
I have a recursive model like this: public class Node { public int Id
I have an Interface like this: namespace QuickRoutes.Model.Utilities { public interface IRoutesManager { bool
I have model that looks like this: public class Lesson { public int Id
I have a model with a property defined like this: [Required(ErrorMessage=Please enter how many
I have a model like this: public class Entity { [Key, Required] public virtual
I have a class like this: class MyClass{ public: MyClass(int Mode); private: std::map <
I'm using FluentNHibernate but NHibernate XML will do. Say I have this model public
I have this query in model: public function Games() { $q = $this->db->select('games.id, games.title,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.