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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:45:37+00:00 2026-05-27T11:45:37+00:00

I have an ASP.NET MVC 3.0 application. Inside the application, I have a Login

  • 0

I have an ASP.NET MVC 3.0 application.
Inside the application, I have a Login View which is strongly typed via a LoginViewModel class. In addition, the Login View can be accessed by two different types of people Employees and Management.

The view is displayed in a < table >. The user must first select (from 2 radio buttons) what type of user he is (Employee or Management) and from the selection, I change the UI and display (show/hide) certain divs.

If Employee is selected, I ask for the Employee Number and Password.

If Management is selected, I ask for the UserCode and Password.

The LoginViewModel has 4 properties:

  • –UserType (represents the selected radio button)
  • –EmployeeNumber (represents the textbox for Employees)
  • –UserCode (represents the textbox for Management)
  • –Password (represents the textbox for the Password regardless of who is selected)

Since the UI changes according to the selected radio button, I can not use the [Required] attribute on both EmployeeNumber and UserCode properties because if I do, the < form > won’t submit (since one of the fields will be hidden).

To overcome this limitation/problem, I have to remove the [Required] attribute on both properties and presumably do this client side.

For the record, I am not using MicrosoftMVCValidation.js but instead jquery.validate.min.js and jquery.validate.unobtrusive.js

Question 1)

When searching for examples online I’ve seen many of them including this file:

jquery.unobtrusive-ajax.min.js

What’s the purpose of this file and what’s its correlation with client side validation (if any)?
Do I really need it? Shouldn’t jquery.validate.min.js and jquery.validate.unobtrusive.js suffice?

Question 2)

I understand that one could write a custom Validation Attribute and place it on the EmployeeNumber or UserCode property but if I do so (and knowing that I will be hiding one of them in the UI) how do I prevent myself from getting the same issue I had with the [Required] attribute? (meaning not being able to submit the form because one is hidden)

Can I simply do this directly in the View? Would anyone be so kind to show me a quick example?

Thanks

Oh and yes…the jquery-1.7.1.min.js is included in the master layout (in case anyone asks).

  • 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-05-27T11:45:38+00:00Added an answer on May 27, 2026 at 11:45 am

    To answer your first question, jquery.unobtrusive-ajax.min.js is not for unobtrusive validation. It is for using the @Ajax html helper (@Ajax.Form, etc).

    To answer your second question, I would actually create 2 totally different viewmodels and corresponding forms for this. When user selects with radio button, show the correct form. That means, don’t combine Employee and Management into the same LoginViewModel. You can then treat validation, as well as other view logic, separately between the two.

    Update

    To answer your question about strong typing, you would create 2 different (partial) views. One would have @model EmployeeLoginViewModel and the other would have @model ManagementLoginViewModel. To render them on a a single page, there are a few different approaches. You can have a single LoginViewModel that contains an instance each of ManagementLoginViewModel and EmployeeLoginViewModel, and then use @Html.EditorFor(m => m.Employee) and @Html.EditorFor(m => m.Management). However this approach only works if your partial views are in the EditorTemplates folder.

    Another approach is to use @Html.Action(), and have 2 different controller action methods to return the partial views.

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

Sidebar

Related Questions

I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7
I have this view in an ASP.NET MVC application: <% var path = Path.Combine(HttpRuntime.AppDomainAppPath,
I have written an ASP.NET MVC application that runs inside an IFrame. When one
i have the following script inside my asp.net MVC application to bounce the image
I have an asp.net mvc application with a route similar to: routes.MapRoute(Blog, {controller}/{action}/{year}/{month}/{day}/{friendlyName}, new
I have an ASP.NET MVC application, when a user clicks on the submit button
I have an asp.net mvc application and i am trying to assign value to
I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This
I have an Asp.Net MVC application that works in the vs.net development web server.
I have a ASP.NET MVC application using NHibernate and the application runs fine when

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.