Solved

mvc, client validation

Posted on 2013-11-15
1
318 Views
Last Modified: 2013-11-22
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
Comment
Question by:solution1368
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now