Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MVC Modify the Validation Message

Posted on 2014-01-08
1
145 Views
Last Modified: 2014-02-18
Hi

How do I modify/customise the validation messages?

At the moment if I don't enter a field, I get "The value '' is invalid."
I would like to make this more personalised or at least change it to "You must enter this field" or "You must enter your name"
0
Comment
Question by:elmbrook
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39767844
Assuming you're using standard validation mechanism, then you can decorate the properties of your model with data annotations. Something like:
public class Person
{
     [Required(ErrorMessage = "You must enter your first name")]
     public string FirstName { get; set; }

     [Required(ErrorMessage = "You must enter your last name")]
     public string LastName { get; set; }
}

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

789 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