coercing uppercase

Could someone please help me out with the proper syntax to coerce data to upper case?

my statement is :
clientidold=arguments[3]
I want to ensure that the result field, clientidold, is upper case.
Ive tried:
clientidold=arguments[3].toUpperCase and
clientidold.toUpperCase=arguments[3] and
clientidold=arguments[3];clientidold.toUpper=clientidold and
clientidold=arguments[3];clientidold=clientidold.toUpperCase

To make the field: clientidold uppercase do this:

clientidold = clientidold.toUpperCase

Is there a way to force a text field to Title Case without a mask (format) that also forces the backend to Title Case as well?

Hey John,

As there is no function for title case you would need to :

  • split the string into an array of words using a space delimiter
  • extract the first character of each array element and coerce it to be upper case
  • reconstruct each array element using the upper case first charcater
  • join the array elements together again using the same space delimiter to get your original string back

And that’s the easy part :D

Then you have to worry about potential non-standard words or names like McDonald or van Helsing

Maybe there is a Regex methodology which could do this in a much cleaner way ?

Cheers
Harry

Questions like this raise another question to me.

At which point stops the responsibility of the developer and starts that of the user?..

IT2Be:
At which point stops the responsibility of the developer and starts that of the user?..

You mean this would be a typical case of “User Error! Replace User and Press Any Key To Continue” ?

;)

Yep!

[snippet case=‘really happened this week’]
Imagine a blond girl using a system for order management.
Imagine this blond user bypassing 2!!! messages not to delete an organization FREQUENTLY
Imagine these organizations are captured in an archive so the organization and related data can be restored
Imagine the organization and related data are set up to be deleted all when an organization is really deleted
Imagine the blond working with a keyboard :)
Imagine the blond using an obscure key combination that deletes the organization
Imagine me browsing in the history and log files finding out that the blond, in whatever way, bypassed ALL settings and ONLY deleted the organization WITHOUT related data
Imagine me being relieved because the issue was not so big
Imagine me being surprised that this can actually be happening
[/snippet]

The above is a typical case of user replacement :lol:

hmm..you should file a bugreport…the related data should have been deleted.

:twisted: ;)

hmm..you should file a bugreport…the related data should have been deleted.

I agree, instead I filed a bugreport for the user :)

Providence1:
Is there a way to force a text field to Title Case without a mask (format) that also forces the backend to Title Case as well?

Google is the best friend of lazy programmers. A search for JavaScript title case gives numerous hits.

I’d use a mask on the field for display purposes and in the onRecordUpdate/Insert of the table, check if the text is allready properly titleCased, and if not, make it titleCased.

Paul

I would hire Marcel’s blond girl to tlTle cAsE for you.

Harry Catharell:
Hey John,

As there is no function for title case you would need to :

  • split the string into an array of words using a space delimiter
  • extract the first character of each array element and coerce it to be upper case
  • reconstruct each array element using the upper case first charcater
  • join the array elements together again using the same space delimiter to get your original string back

And that’s the easy part :smiley:

Then you have to worry about potential non-standard words or names like McDonald or van Helsing

Maybe there is a Regex methodology which could do this in a much cleaner way ?

Cheers
Harry

http://mike.dewolfe.bc.ca/uppercase.asp

Well done, Jan

Puts my little function well into the shade 8)

var textblock = forms.the_form.the_field;

var textarray = textblock.split(" ");

for ( var i = 0 ; i < textarray.length ; i++ )
	{
	var element_length = textarray[i].length;
	var firstchar = textarray[i].substr(0 , 1);
	var firstchar_upper = firstchar.toUpperCase();
	var return_string = firstchar_upper + textarray[i].substr(1 , element_length - 1);
	textarray[i] = return_string;
	
	}

var textblock = textarray.join(" ");

forms.the_form.the_field = textblock;

Cheers
Harry

I agree, instead I filed a bugreport for the user

Do you have any idea how many users I would have to do that for?

… most of them…