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

The Archive Base Latest Questions

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

Using Data Annotations to specify validation rules for a model, I want to set

  • 0

Using Data Annotations to specify validation rules for a model, I want to set the initial value for the Required attribute so that it fails if it’s equal to that value. This was an option in webforms using the validation controls, but I don’t see similar using Data Annotations.

If there’s no built in way to do it, I’ll probably just build a new Required Attribute that inherits from it.

UPDATE: Based on comments/answers, I definitely know this is not an ideal situation and I should be using the placeholder attribute of HTML5. However, I need to do this for an existing form that already had shadow text being added in a non-ideal way.

  • 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-24T05:28:09+00:00Added an answer on May 24, 2026 at 5:28 am

    I wouldn’t handle that in MVC, I’d work on getting the shadow text to not post with the form. HTML 5 has “placeholder”. I’d use that or implement something like it: http://davidwalsh.name/html5-placeholder

    Check this out for a simple quick placeholder approach that degrades properly in non-html5 browsers:

    JQuery placeholder HTML5 simulator

    Just add the placeholder attribute to your textboxes and use that javascript to make it work regardless of HTML version.

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

Sidebar

Related Questions

Is there some way using data annotations that I can check the value of
I am using Data Annotations to validate my Model in ASP.NET MVC. This works
So I have been using data annotations for my validation in an MVC project
I have some problems with validation using Data Annotations in ASP.NET MVC 2. For
I'm using MVC2 with data annotations for validation on my page. I require a
I'm using ASP.NET MVC 3 code-first and I have added validation data annotations to
I am using data annotations to validation my class properties. A requirement has emerged
I am trying to get client validation working in MVC3 using data annotations. I
I want to map a many to may relationship using ONLY data annotations so
I'm using linq to SQL and MVC2 with data annotations and I'm having some

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.