I have a database field (postcode) that I want to contain upper case characters, spaces and numbers. No lower case or other punctuation. I'd like to deal with that as declaratively as possible. One way would be to use a regular expression DataAnnotation to validate, [A-Z][0-9]\w
(or similar - I'm not a regular expression expert, but I'm sure the right regular expression is there to be found). That would do half of what I want - it would force the user to input in uppercase, but it wouldn't convert to uppercase.
If I want to convert to uppercase there are some solutions in Stack Overflow question How can I force input to uppercase in an ASP.NET textbox?, but none of them are particularly declarative. At the moment I'm thinking of a combination of the validation and jQuery to spot anything with a class of "uppercaseonly" and convert the data, but it's a bit messy.
Am I missing anything?