capitalize first letter in Last Name text field in JavaScript

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 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
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

22-11-2016

eugzl wrote...

I found online code but it works in FormCalc in exit event. I need same in JavaScript. How to convert that code 

  1. txt = Concat(Upper(Left(txt,1)), Lower(Right(txt,Len(txt)-1)))

to JavaScript? The txt field name.

Thanks. 

 

Hi 

There are 3 option to convert Excel formula to JS:

1. By creating JavaScript code corresponding to it.

2. Use Third part JQuery plugins to run Excel formules.

Link:-http://www.igniteui.com/javascript-excel-library/excel-formulas

Demo:- http://jsfiddle.net/gh/get/jquery/1.9.1/igniteuisamples/jsfiddle-samples/tree/master/EN/HtmlSamples/...

3. Excel to JS convertor :  

    Link:- http://excelformulabeautifier.com/  (Choose "Formula to JavaScript") 

 

I hope this would help you.

~kautuk

Answers (4)

Answers (4)

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

29-09-2016

I found online code but it works in FormCalc in exit event. I need same in JavaScript. How to convert that code 

txt = Concat(Upper(Left(txt,1)), Lower(Right(txt,Len(txt)-1)))

to JavaScript? The txt field name.

Thanks. 

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,200 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

29-09-2016

Hi 

I am not sure what exactly is you use case. I would request you to please explain it bit more.

But, if it is something related to converting First letter of Last Name in Dialog field to Capital, then we can certainly do it :

1. Dialog validation: in this validation check, you can specify any checks you would like to do.

Link:- http://www.nateyolles.com/blog/2016/02/aem-touch-ui-custom-validation

//  

$.validator.register({
  selector: '.field-phonenumber',
  validate: function(el) {
    var field,
        value; // Nay Javascript/Jquery condetions that you would like to check.

    field = el.closest(".coral-Form-field");
    value = el.val();

    if (!/^\d{3}-\d{3}-\d{4}$/.test(value)) {
      return Granite.I18n.get('The field must be a phone number in the format of "xxx-xxx-xxxx"');
    }
  },

Another Reference article for Dialog Validation is :- https://helpx.adobe.com/experience-manager/using/creating-touchui-validate.html

 

For JavaScript  to convert all first letter to capital:-

//var saa = sa.toLowerCase();
    var sb = saa.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
    var sc = sb.replace(/\s+/g, '-');
    return sc;

 

I hope this would help you.

~kautuk

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 smacdonald2008. Thanks for replay.

I need code to capitalize first letter LastName field in form that I developed in Adobe Experience Designer. I'm thinking will better for Change or Exit event. If you know how to get result I will appreciate for help.

Thanks.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

28-09-2016

See this community thread - so use the same logic that is shown in this thread in AEM: 

http://stackoverflow.com/questions/6256550/how-to-make-it-so-a-string-has-to-start-with-a-capital-le...

Hope this helps...