Looking for a way to convert the text in my text field on my form to proper case when the user tabs out of the field. I would think i could use the javascript to validate this. New to LiveCycle ES. any help would be appreciated , Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Place the below code in the exit event with JavaScript to convert the text to proper case.
this.rawValue = this.rawValue.replace(/\b([a-z])/g, function (_, initial) {return initial.toUpperCase();});
Thanks
Srini
Views
Replies
Total Likes
The attached contains a repeating subform that manages the case of the partDescription as follows:
// form1.purchaseOrder.detail.partDescription::exit - (JavaScript, client)
if (!(this.isNull || this.rawValue == "")) {
var str = this.rawValue;
var char1 = str.substring(0,1);
var char2_n = str.substring(1,str.length);
this.rawValue = char1.toUpperCase() + char2_n.toLowerCase();
}
Steve
Views
Replies
Total Likes
Place the below code in the exit event with JavaScript to convert the text to proper case.
this.rawValue = this.rawValue.replace(/\b([a-z])/g, function (_, initial) {return initial.toUpperCase();});
Thanks
Srini
Views
Replies
Total Likes
That's slick Srini - could you break it down for me so I can see how it works? How does the first letter get passed to the internal function?
I still have a lot to learn in JavaScript.
Views
Replies
Total Likes
The regular expression is the key here.
/\b([a-z])/g -> will check for all the first character in each word and then pass it to the internal function.
If more than one word is available, then it will call the function that many times.
Thanks
Srini
Views
Replies
Total Likes
I get the regex part (except for the /g) but I'm unsure how it passes the letter to the function, is it the underscore?
Is there a name for this type of statement so I can read up on it?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies