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

  • SEARCH
  • Home
  • 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 8348585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:44:08+00:00 2026-06-09T07:44:08+00:00

I have some checkboxes that are required to be checked before the user can

  • 0

I have some checkboxes that are required to be checked before the user can go to the next page. What is the best way to display a validation message?

View:

@Html.CheckBox("terms_eligibility")
@Html.CheckBox("terms_accurate")
@Html.CheckBox("terms_identity_release")
@Html.CheckBox("terms_score_release")

Controller:

[HttpPost]
public ActionResult Review(ReviewModel model)
{
    // Make sure all Terms & Conditions checkboxes are checked
    var termsEligibility = Request.Form.GetValues("terms_eligibility")[0];
    var termsAccurate = Request.Form.GetValues("terms_accurate")[0];
    var termsIdentityRelease = Request.Form.GetValues("terms_identity_release")[0];
    var termsScoreRelease = Request.Form.GetValues("terms_score_release")[0];

    if (termsEligibility == "true" && termsAccurate == "true" &&
        termsIdentityRelease == "true" && termsScoreRelease == "true")
    {
        return RedirectToAction("CheckOut","Financial");
    }

    return null;
}

EDIT,

I made the suggested changes. Now how do i get the same page to display with error messages?

I changes the attributes in the model to this

 [RequiredToBeTrue(ErrorMessage = "*")]

here’s the conroller

[HttpPost]
public ActionResult Review(ReviewModel model)
{


    if(ModelState.IsValid)
    {
        return RedirectToAction("CheckOut", "Financial");
    }

    return RedirectToAction("Review");
}
  • 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-09T07:44:10+00:00Added an answer on June 9, 2026 at 7:44 am

    I’d recommend you using a view model and a custom validation attribute:

    public class RequiredToBeTrueAttribute : RequiredAttribute
    {
        public override bool IsValid(object value)
        {
            return value != null && (bool)value;
        }
    }
    

    and the view model:

    public class MyViewModel
    {
        [RequiredToBeTrue]
        public bool TermsEligibility { get; set; }
    
        [RequiredToBeTrue]
        public bool TermsAccurate { get; set; }
    
        [RequiredToBeTrue]
        public bool TermsIdentityRelease { get; set; }
    
        [RequiredToBeTrue]
        public bool TermsScoreRelease { get; set; }
    
        ... some other properties that are used in your view
    }
    

    and the view will of course be strongly typed to the view model:

    @model MyViewModel
    
    @Html.ValidationSummary(false)
    @using (Html.BeginForm())
    {
        @Html.CheckBoxFor(x => x.TermsEligibility)   
        @Html.CheckBoxFor(x => x.TermsAccurate)   
        @Html.CheckBoxFor(x => x.TermsIdentityRelease)   
        @Html.CheckBoxFor(x => x.TermsScoreRelease)   
        ...
        <button type="submit">OK</button>
    }
    

    and finally your controller action will take the view model as parameter:

    [HttpPost]
    public ActionResult Review(MyViewModel model)
    {
        if (!ModelState.IsValid)
        {
            // there were validation errors => redisplay the same view  
            // so that the user could fix them
            return View(model);
        }
    
        // at this stage we know that validation succeeded =>
        // we could proceed in processing the data and redirecting
        ...
    
        return RedirectToAction("CheckOut", "Financial");
    }
    

    Notice that things like Request.Form.GetValues("terms_eligibility")[0]; and termsEligibility == "true" are really not the kind of code you would like to see in a properly written application.

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

Sidebar

Related Questions

I have a page with some checkboxes and a submit button. I use AJAX
I have some checkboxes that act as search filters. These search filters trigger an
I have a list. In that I have some checkboxes. I am trying to
I have some checkboxes and I would like to allow multiple selections, only that
I have a form that has a series of check boxes and some line
I have datagridview with checkbox column, but I want, that some of the columns
I have some checkboxes bound to an array in my model. This works great,
I have some checkboxes like this: <input type=checkbox name=regions[] value=north-east />North East<br /> <input
i have a form with some checkboxes on it i want to save those
I am working on zend. I have a form with some checkboxes. I want

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.