Function to Convert the first letter of a string to Capital in coldfusion



<cfform>
      Enter the String: <cfinput type="text" name="strUcase">
      <cfinput type="submit" name="btn_ucase" value="Submit">
</cfform>
<cfif isdefined('form.btn_ucase')>
      <cfinvoke method="CapFirst" returnvariable="str1">
      <cfinvokeargument name="str" value="#form.strUcase#">
      </cfinvoke>
      <cfoutput>Converted String is: #str1#</cfoutput>
</cfif>   

<cffunction name="CapFirst" returntype="string" output="false">
    <cfargument name="str" type="string" required="true" />
   
    <cfset var newstr = "" />
      <cfif Len(str) GTE 1 >
            <cfset newstr = UCase(left(arguments.str,1)) & Right(arguments.str,Len(arguments.str)-1)>
      </cfif>
    <cfreturn newstr />
</cffunction>

Comments

Popular posts from this blog

how to add new line in google form questions | Fix for next line issue in google form questions

How to add new line in dropdown type question in google forms