Solved

mvc, client validation

Posted on 2013-11-15
1
320 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
ID: 39653358
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

785 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