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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:11:08+00:00 2026-05-24T20:11:08+00:00

[Required(ErrorMessage = ONLY TYPE IN NUMBERS!)] [Display(Name = Telefono Fijo)] public int Telephone {

  • 0
[Required(ErrorMessage = "ONLY TYPE IN NUMBERS!")]
[Display(Name = "Telefono Fijo")]        
public int Telephone { get; set; }

Basically, I’d like that when someone types in a letter, that text up there should display.

Here’s my view:

<div>
    @Html.LabelFor(model => model.RegisterModel.Telephone)
    @Html.EditorFor(model => model.RegisterModel.Telephone)
    @Html.ValidationMessageFor(model => model.RegisterModel.Telephone)
</div>

When I type in letters, I get:

"The field Telefono Fijo must be a number."

And when I don’t type in ANYTHING, I get:

"ONLY TYPE IN NUMBERS!"

Any ideas? I only want the custom message to show.

  • 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-24T20:11:09+00:00Added an answer on May 24, 2026 at 8:11 pm

    You should use RegularExpressionAttribute:

    [RegularExpression(@"^\d+$", ErrorMessage = "ONLY TYPE IN NUMBERS!")]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this class: public class Product { [Required(ErrorMessage = empty name)] public string
I have a model item public class EntryInputModel { ... [Required(ErrorMessage = Description is
Model: using System.ComponentModel.DataAnnotations; using MySite.Validators; namespace MySite.Models { public class AddItem { [Required(ErrorMessage =
I have a basic MVC view model with annotations, for example: [Required(ErrorMessage=Your Name Required)]
I've got a view model like this: public class SignUpViewModel { [Required(ErrorMessage = Bitte
Say I have a model like this public class User { [Required] [StringLength(14, ErrorMessage
I have the following POCO's: [PetaPoco.TableName(Customer)] [PetaPoco.PrimaryKey(ID)] public class User { [Required(ErrorMessage = Please
With Data Annotations for example, besides decorating members like this: [Required( ErrorMessage = You
Instead of showing an error message 'Name is required' I would like to change
I have the following code working [Required(ErrorMessage = Price is required.)] [Range(typeof(Decimal), 1, 9999,

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.