Function to evaluate whether a string is all UPPER

  • Thread starter Thread starter Brad Smith
  • Start date Start date
B

Brad Smith

I'm trying to clean up strings in a web form before I plug the fields
into a database. Lots of folks like to leave caps lock key on and
yell their form entries.

I can figure out how to change strings to sentence case, but I don't
want to do it to every string since some correctly entered words e.g.
"to" would be converted unnecessarily (to "To"). I'm willing to live
with the over correction on a few strings, but don't want to apply it
to the entire database.

Has anyone used a function to evaluate whether a string has been
entered all in upper case?


Thanks,

Brad Smith
pbs at myrealboxNOSPAM.com
remove NOSPAM from address and replace at with @ to email me directly
 
Convert the string to all upper case, and compare the result to the original
string. If they are equal, the original string is all upper case.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.
 
Hi Brad,

Could you try this:

string a = "Dodo";
if (a == a.ToUpper())
{
// the string is all in uppercase!
}

Thanks,
Blaise Pascal Tine (MSFT).
--------------------
 
Back
Top