capitalize first letter in Last Name text field in JavaScript

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)

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)

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. 

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

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.