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