Solved

MVC4 - Modify the Validation Message

Posted on 2014-10-23
1
105 Views
Last Modified: 2014-10-28
Hi

How do I modify/customise the validation messages in  MVC4?

At the moment if I don't enter a field, I get "The value '' is invalid."

I would like that to say "This is an invalid email address"

I am using Entity Framework for my data if that makes a difference

Thanks
0
Comment
Question by:elmbrook
1 Comment
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 500 total points
ID: 40402155
I'm assuming you have a [Required] attribute on the property in your model. If you'd looked up the Required attribute on MSDN (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.requiredattribute(v=vs.110).aspx) you would have seen it has an ErrorMessage property (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.errormessage(v=vs.110).aspx) that allows you to specify the message that should be shown.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is "public object" in C#? 3 47
Video Player 11 23
MediaHelp 4 23
c# - Best approach for objects in functions 3 17
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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