I used this code from another post:
function toTitleCase(s)
{
var re1 = /(\w)(\w*)/; // Make an array of words that are in the input string
var a1 = s.split(/\s+/g);
for (i = 0; i < a1.length; i++ )
{
var a2 = a1[i].match(re1); // Capitalize first character of word
a1[i] = a2[1].toUpperCase() + a2[2];
// Alternatively, also convert rest of word to lower case
a1[i] = a2[1].toUpperCase() + a2[2].toLowerCase(); }
return a1.join(" ");
}
In the field action, i'm using a mouse up event to run the following javascript to call the function:
this.getField("name").value = toTitleCase(("name")).value;
The errors i'm getting from the debugger is this.
InvalidSetError: Set not possible, invalid or unknown.
Field.value:1:Field name:Keystroke
You also have to pass the field value to the function and not the character string of the field name.
event.value = toTitleCase(event.value);
George Kaiser