Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:12:42+00:00 2026-06-01T17:12:42+00:00

I work in ASP MVC3. I have a model for the input of the

  • 0

I work in ASP MVC3. I have a model for the input of the contact information of a customer.
The information is required. When the viewstat is not valid the textboxes must have a red border (this works) en no errormessage. But when the emailinput is invalid the the error must be visible on the view. So only the errormessage of the emailannotation must be visible and not of the requiredannotation. I have no idea how to do this.

model:

    [Required]
    public string FirstName { get; set; }
    [Required]
    public string Name { get; set; }
    [Required]
    public string Address { get; set; }
    [Required]
    public string PostalCode { get; set; }
    [Required]
    public string City { get; set; }
    [Required]
    public string Country { get; set; }
    [Required]
    public string PhoneNumber { get; set; }
    public string Fax { get; set; }
    [Required]
    [Email]
    public string Email { get; set; }

view:

<div class="row-fluid">
    <div class="span6">
                <div data-role="fieldcontain" class="ui-hide-label">
                    <label for=@Lingo.language.Obj_Telefoon>@Lingo.language.Obj_Telefoon</label>
                    <span>@Html.TextBoxFor(m => m.PhoneNumber, new { style = "width:90%!important;", placeholder = @Lingo.language.Obj_Telefoon })</span>
                </div>               
    </div>
    <div class="span6">
        <div data-role="fieldcontain" class="ui-hide-label">
            <label for=@Lingo.language.Obj_Fax>@Lingo.language.Obj_Fax</label>
            <span>@Html.TextBoxFor(m => m.Fax, new { placeholder = @Lingo.language.Obj_Fax })</span>
        </div>  
    </div>
 </div>
 <div class="row-fluid">
    <div class="span12">
        <div data-role="fieldcontain" class="ui-hide-label">
            <label for=@Lingo.language.Obj_Email>@Lingo.language.Obj_Email</label>
            <span>@Html.TextBoxFor(m => m.Email, new { style = "width:98%!important;", placeholder = @Lingo.language.Obj_Email })</span>
            <span>@Html.ValidationMessageFor(m => m.Email)</span>
        </div>  
    </div>
 </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:12:43+00:00Added an answer on June 1, 2026 at 5:12 pm

    If you want it to be required, but don’t want to show the “required” error message, you could set the message to be a single space (to avoid the run-time error “Either ErrorMessageString or ErrorMessageResourceName must be set, but not both.”)

    [Required(ErrorMessage = " ")]
    [Email(ErrorMessage = "Must be a valid email address.")]
    public string Email { get; set; }
    

    If you don’t already have the Email attribute, you can create a class file (e.g. EmailAttribute.cs) containing:

    using System.ComponentModel.DataAnnotations;
    
    public class EmailAttribute: RegularExpressionAttribute {
        public EmailAttribute()
          : base(@"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$") { }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ADO.Net entity framework with asp.net mvc3. I have a model which
I have an employee class in model for ASP.NET MVC3. There is a field
Work on asp.net vs05. I have three type of value Like:IsDesign,IsPrinting,IsInstall they are bit
(I work in asp.net) I'm looking for a way to have a div with
The ASP.NET validation does not seem to work inside ASP:FormView. Can someone let me
Why ItemStyle-VerticalAlign=Middle not work in asp:GridView?, this is my code <asp:GridView ID=GridView1 runat=server RowStyle-VerticalAlign=Middle
I hope that title is clear enough. I have 2 projects, MyProject.Website (ASP.NET MVC3
I have a Razor/ASP/MVC3 web application with a form and a Submit button, which
I have an ASP.NET MVC control which has to do some work to format
I'm using jQuery Validate Unobtrusive with ASP.NET MVC3 Razor. I have a page with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.