I have a database field (zip code) in which I want to contain uppercase characters, spaces and numbers. No lowercase characters or other punctuation marks. I would like to consider this as declarative as possible. One way is to use the DataAnnotation regular expression for validation, [A-Z][0-9]\w(or the like - I'm not a regular expression specialist, but I'm sure that the correct regular expression will be found there). That would do half what I want - it will force the user to type in uppercase, but will not convert to uppercase.
If I want to convert to uppercase, there are some solutions in the question How can I force input to uppercase in an ASP.NET text box? but none of them are particularly declarative. At the moment, I am thinking of a combination of validation and jQuery to detect something with the "uppercaseonly" class and transform the data, but it is a bit dirty.
Did I miss something?
source
share