capitalize first letter in Last Name text field in JavaScript

Avatar

Avatar

eugzl

Avatar

eugzl

eugzl

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

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K
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

eugzl

Avatar

eugzl

eugzl

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

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K
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

eugzl

Avatar

eugzl

eugzl

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

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

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...