Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

capitalize first letter in text field

Avatar

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
eugzl
Level 2

28-09-2016

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

30-09-2016

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

Answers (4)

Answers (4)

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

30-09-2016

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();

Avatar

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
eugzl
Level 2

30-09-2016

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.

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

30-09-2016

Something is not correct. I get a return value of Empty

Avatar

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile
_Bruce_Robertson
MVP

29-09-2016

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