Skip to main content
November 6, 2009
Answered

isUppercase(string) ?

  • November 6, 2009
  • 1 reply
  • 1677 views

Hi, I would like to find a function that check if a string is all written in Uppercase and if so, to capitalize it.

I'll capitalize it with CSS using: text-transform: capitalize, but the only coldfusion function I found on line check only a character:

<cfscript>
  function isUpperCase(char) {
     if (Asc(char) gte 65 and Asc(char) lte 90)
        return true;
     return false;
  }
</cfscript>

Someone is able to write it in a way that check if a whole string is UPPERCASE ?

I'm not able to ... I should study, I know, but I'm in hurry ...

This topic has been closed for replies.
Correct answer Jochem van Dieten

The IS operator does a case insensitive comparison. Use the compare() function instaed.

1 reply

Inspiring
November 6, 2009

Uppercase the string using the UCase() function and then check if it is identical to the original string.

November 6, 2009

Do you meaqn checking something like:

<cfif string is UCase(string)> ?

It seems not working ...

Jochem van DietenCorrect answer
Inspiring
November 6, 2009

The IS operator does a case insensitive comparison. Use the compare() function instaed.