Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

capitalize first letter in Last Name text field in JavaScript

Avatar

Level 5

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. 

1 Accepted Solution

Avatar

Correct answer by
Administrator

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



Kautuk Sahni

View solution in original post

5 Replies

Avatar

Level 10

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

Avatar

Level 5

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

Administrator

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



Kautuk Sahni

Avatar

Level 5

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

Correct answer by
Administrator

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



Kautuk Sahni