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

  • Home
  • SEARCH
  • 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 6546903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:45:55+00:00 2026-05-25T11:45:55+00:00

This question has to have been asked before, but I think the search terms

  • 0

This question has to have been asked before, but I think the search terms are too generic for me to find the answer I’m looking for, so I’ll ask it again.

I have a model with an int property, and a range annotation.

If the user enters something other than an int, the validation message responds with The value '<bad data>' is not valid for '<property name>'… which is great, but I want to provide a bit more feedback, i.e., Expecting an integer value in this field..

Since this validation fails before the other validators take a look, I don’t know how (or if it’s possible) to override the default validator message for this.

What are my options?

per request, I am posting the code, but there’s not a lot to it:

[Range(0,65535, ErrorMessage="Port must be between 0 and 65535.")] 
public int Port { get; set; }

There is validation that occurs before it reaches the RangeAttribute. I want to replace the default message with one of my own choosing.

  • 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-05-25T11:45:55+00:00Added an answer on May 25, 2026 at 11:45 am

    If you’re using standard annotations, you should be able to override the error message with something like this:

    [MyAnnotation(...., ErrorMessage = "My error message")]
    public int myInt { get; set; }
    

    Or do you actually want to append to the default error message instead of replacing it (not clear in question)?

    Update: Misread — suggest this as the answer: How to change the ErrorMessage for int model validation in ASP.NET MVC? or better yet How to change 'data-val-number' message validation in MVC while it is generated by @Html helper

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this question has been asked before, but I'm too frustrated to find
This question has been asked before ( link ) but I have slightly different
I know this question has been asked here before, but I don't think those
I know this question has been asked before but I have a design question
Well, I'm sure this question has been asked before but I'm yet to find
First off, apologies if this question has been asked before but I couldn't find
I know this question has been asked many times before but I can't find
I know this question has been asked before, but I ran into a problem.
I know this question has been asked a bit before. But looking around I
I know this specific question has been asked before , but I am not

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.