Hi All.
I design form in LiveCycle and I would like capitalize first letter in Last Name text field. Could someone let me know how to capitalize it in JavaScript?
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
I think I finally got this to work. On the Exit event for the field I put:
this.rawValue = this.rawValue.toLowerCase().replace(/\b[a-z]/g, function replacer(match) { return match.toUpperCase(); });
this forces the first letter of each word to UpperCase
Views
Replies
Total Likes
Hi,
You could add the following JavaScript code in the exit event of your text field.
if (!this.isNull)
{
this.rawValue = util.printx(">?<*",this.rawValue);
}
This changes the first character (represented by the ?) to uppercase (represented by the >) and all trailing characters (represented by the *) to lowercase (represented by the <). If you need to do the same hyphenated names or Van Der Valk's and the like you can try this JavaScript in the exit event;
function toTitleCase(textValue) {
return
textValue.toLowerCase().replace(/\b[a-z]/g, function replacer(match) { return
match.toUpperCase(); });}
if (!this.isNull)
{
this.rawValue = toTitleCase(this.rawValue);}
Regards
Bruce
Views
Replies
Total Likes
Something is not correct. I get a return value of Empty
Views
Replies
Total Likes
Hi Bruce. Thanks for replay.
Is possible to capitalize all words in Last Name if it contains: space, hyphen, single quote or combination of letters and those characters? If yes. Can you show how to do it?
Thanks.
Views
Replies
Total Likes
If you just want to force everything to upper case then just put this on the fields change event:
xfa.event.change=xfa.event.change.toUpperCase();
Views
Replies
Total Likes
I think I finally got this to work. On the Exit event for the field I put:
this.rawValue = this.rawValue.toLowerCase().replace(/\b[a-z]/g, function replacer(match) { return match.toUpperCase(); });
this forces the first letter of each word to UpperCase
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies