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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:37+00:00 2026-05-26T15:09:37+00:00

I use the validation attribute on the fields of a class and has a

  • 0

I use the validation attribute on the fields of a class and has a requirement like that:
if field ‘a’ is validate succeed then process the validation of field ‘b’ but if the field ‘a’ is not throw validation , ignore the validation of field ‘b’.
does it feasible or i should think in other way?

public class myclass
{
[required]
public string a{get;set;}
[required]
public string b{get;set;]
}

i want:
1.if a pass the validate, then execute b ‘s validate
2.if a not pass the validate , then don’t execute the b ‘s validate

  • 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-26T15:09:37+00:00Added an answer on May 26, 2026 at 3:09 pm

    Check out the MVC.ValidationToolkit

    http://blogs.msdn.com/b/simonince/archive/2011/09/29/mvc-validationtookit-alpha-release-conditional-validation-with-mvc-3.aspx

    It contains these two validations that will help you out.

    • RequiredIfAttribute. This attribute says “this field is required if some other field has value X”. It is used as [RequiredIf(“OtherField”, “TargetValue”)]
    • RequiredEmptyIfAttribute. This attribute says “this field must be empty if some other field has value X”. It is used as [RequiredEmptyIf(“OtherField”, “TargetValue”)]
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that some validation tools use the class attribute to pass options to
How can I use Same Custom Validation Attribute Multiple Times on Same Field or
I'm trying to use Struts validation to check various fields entered by users. If
I am trying to use same validation function for all my controls. But I
When i use RequiredFieldValidator for Validation FCKEditor , The first time that the form
I have a view model that looks like this: public class VenueIndexViewModel : BaseViewModel
I am using a Remote validation attribute on my view model to validate a
I would like use data annotations to handle validation in my Silverlight app. The
Is there an attribute that I can use with ASP.NET MVC 3 to prevent
MVC2 comes with a nice sample of a validation attribute called PropertiesMustMatchAttribute that will

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.