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.
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.