title: Require validation only if the field is visible
body: <p>I am using the <code>[Required]</code> attribute for the client-side validation in ASP.NET MVC 3.</p>
  
  <p>The class looks as:</p>
  
  <p></p>
  
  <pre><code>public class User
  {
      [Required(ErrorMessage = "First Name is required")]
      public string FirstName { get; set; }
  }
  </code></pre>
  
  <p>I want the field <code>FirstName</code> to be validated only if it's visible, which will be shown only on certain conditions. How can I do that?</p>
  
  <p>I have used the following, but still it looks to validate for the required field of that hidden field.</p>
  
  <p></p>
  
  <pre><code>$('#registerForm').validate({ ignore: ":not(:visible)" });
  </code></pre>