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 7742513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:17:41+00:00 2026-06-01T09:17:41+00:00

I am getting The value ‘abc’ is not valid for fieldName. as error message.

  • 0

I am getting The value 'abc' is not valid for fieldName. as error message. which is default error message and i want to override it in easier way.
as of now what i have tried is listed below

  • [RegularExpression(@"^\d+$",ErrorMessage="enter numeric value")]
  • [Integer(ErrorMessageResourceType = typeof(appName.Resources.abc.Resource),
    ErrorMessageResourceName = "error_numeric")]
  • [RegularExpression("([1-9][0-9]*)")]
  • Range(1,int.max,ErrorMessage="enter numeric value")

    but failed to change default error message.

    Suggest me the easiest possible way to do this.

       using System;
       using System.Collections.Generic;
       using System.Linq;
       using System.Web;
       using System.ComponentModel.DataAnnotations; 
       using System.Web.Mvc;
    
      namespace blueddPES.ViewModels
         {
         public class ContactViewModel
            {
             [Integer(ErrorMessage="sdfdsf")]
             public int? hp { get; set; }
            }
    
  • 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-01T09:17:42+00:00Added an answer on June 1, 2026 at 9:17 am

    Easiest way is to use Data Annotations Extensions. It has some useful attributes for things like Integers, etc.

    Or you could write your own, like in: How to change ‘data-val-number’ message validation in MVC while it generate by helper

    Edit: Added complete sample after comments.

    I created a sample vanilla MVC 3 project and then did the following:

    1. Added NuGet package DataAnnotationsExtensions.MVC3

    2. Added a Model class:

      public class IntegerSample
      {
          [Required(ErrorMessage="Dude, please fill something in!")]
          [Integer(ErrorMessage="Are you stupid? Just fill in numbers only!")]
          public int? TestValue { get; set; }
      }
      
    3. Added a Home Controller:

      public class HomeController : Controller
      {
          //
          // GET: /Home/
          public ActionResult Index()
          {
              return View();
          }
      }
      
    4. Added a Home View:

      @using (Html.BeginForm()) {
          @Html.ValidationSummary(true)
          <fieldset>
              <legend>IntegerSample</legend>
              <div class="editor-label">
                  @Html.LabelFor(model => model.TestValue)
              </div>
              <div class="editor-field">
                  @Html.EditorFor(model => model.TestValue)
                  @Html.ValidationMessageFor(model => model.TestValue)
              </div>
              <p>
                  <input type="submit" value="Save" />
              </p>
          </fieldset>
      }
      

    I hope you get some more insights using this sample code. When I run this sample, it works just as you’d want to expect.

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

Sidebar

Related Questions

Not getting value of radio button which i disable using JQuery before page submit.
I am not getting the value of all the checkboxes selected. It just gives
I have used echo $query to see whether it is getting value or not
I am getting value from a text field. I want to show an alert
I am getting value from JSON it gives exception var is not CFString. below
I've had a hard time sitting in front of UML and getting value out
I am getting the value of a fckeditor with javascript to show in a
hi from my db i am getting a value as string type and when
The xmlns attribute in the following code stops me getting the value I need.
IN JAVA CODE IN JSP as below i m getting null value for fieldnoOfRecords.

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.