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 8908219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:07:26+00:00 2026-06-15T03:07:26+00:00

I want to create a register form in mvc 4 application. So, when user

  • 0

I want to create a register form in mvc 4 application. So, when user registers, in that time I want to define user’s status (he is programmer or not) and to show (or hide) dynamically some extra fields to fill depending on user’s choice.

In default case, all fields seems, if user is not programmer (by unchecking checkbox field), to hide Language, Site and Probation fields. My register model is like this:

public class RegisterModel
    {
        [Required]
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "*", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "*")]
        public string ConfirmPassword { get; set; }

        [Display(Name = "Profession")]
        public bool IsProgrammer { get; set; }

        [Required]
        [Display(Name = "Language")]
        public string Language { get; set; }

        [Required]
        [Display(Name = "Site")]
        public string Site { get; set; }

        [Required]
        [Display(Name = "Probation")]
        public string Probation { get; set; }            
    }

If user is programmer, Language, Site and Probation fields are required, user must fill them.

How should I create Register model that, if user is not programmer, Language, Site and Probation fields not required and let to register ?

My second question is that, how show (hide) fields dynamically, when checkbox is checked (unchecked)?

  • 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-15T03:07:27+00:00Added an answer on June 15, 2026 at 3:07 am

    Quick search on ‘mvc asp.net conditional required field’ gave me these few links:

    Conditional Data Annotation

    Using IValidatableObject

    Flexible Conditional Data Annotation

    These are more targeted towards server-side validation.

    So to answer your questions:

    1. Check out the links, they will be helpful
    2. You can use jQuery to achieve that, learn more about jQuery Hide and Show
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a web application that allows users to sign up, register
I want to create sub-domains using PHP on the fly. Suppose a user registers
I want create wordpress website into which I want create user management... That means
I want to create a registration form, with an option to either the register
I have a register form in which i want when the user selects an
I want to create a simple GUI application that displays a map of a
I need to create registration form for an event. Each person that register can
i want create a custom json data from the mssql 2008 results so that
I want create an application with animate button? how can i do? after click
I Have a register Form and I want to validate phone number in C#,

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.