• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

mvc, client validation

I have mvc 3 application that using dataAnnotations to help me doing validation with jquery. everything is working fine. My question is if I have checkbox that meaning that if it is checked, I want to validate first name is required, and just shown on <label></label>
just like what MVC already done for us.

In this case, how can I do it in mvc 3?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Runtime.Serialization;


[Required(ErrorMessage = "Required")]
        [DisplayName("First Name")]
        [DataMember]
        public string defendantFirstName { get; set; }
0
solution1368
Asked:
solution1368
1 Solution
 
Bob LearnedCommented:
Here is one possibility:

Conditional ASP.NET MVC Validation using Data Annotation Attributes
http://www.codeproject.com/Articles/541244/Conditional-ASP-NET-MVC-Validation-using-Data-Anno
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now