5 Replies Latest reply on Jul 2, 2013 9:05 PM by mrosa001

    onchange to InitCap




      I am trying to convert the Item to Initcap , using onchange fuction, to UpperCase works fine,

      but I did not find to Initcap,

      so I created the JavaScript code in the html header page :


      <script type="text/javascript">

      function initCap(str) {

      /* First letter as uppercase, rest lower */

      var str = str.substring(0,1).toUpperCase() + str.substring(1,str.length).toLowerCase();

      return str;





      in the Item P31_PROJETO_CLIENTE


      in the form attribute html :




      but nothing is change after enter data in P31_PROJETO_CLIENTE,


      What I am doing wrong ? 

      thank you.

        • 1. Re: onchange to InitCap
          Jayson Hanes

          you are passing ''P31_PROJETO_CLIENTE' as a string to be initcapped, you need your javascript to return the value of that item, use the $v function something like:



          however, you need to change that item's value after the fact too..  so it's more complicated, something like this:


          onchange="$s(this, initCap($v('P31_PROJETO_CLIENTE'));"

          Furthermore, this will only execute when the input box loses focus, like when you tab or click somehwere else.. you may want to expand this to use an onkeyUP method, so it initcaps as the user types...


          • 2. Re: onchange to InitCap

            Hi JaysonHanes,


            I changed as you suggested but nothing is changing,  ( after tab to another item ).

            is my javascript is correct?


            thank you.

            • 3. Re: onchange to InitCap
              Jayson Hanes

              actually I take that back, perhaps simply use that code in onblur:


              onblur="$s(this, initCap($v('P31_PROJETO_CLIENTE'));"


              if it still isn't working, check your error console to make sure there isn't some other javascript typo or error

              • 4. Re: onchange to InitCap

                there is an error in the onchange or onblur


                if I changed to :


                works fine.

                changed to :

                onblur="$s(this, initCap($v('P31_PROJETO_CLIENTE'));"

                • 5. Re: onchange to InitCap

                  Thank you Jayson, 


                  then problem was it was missing ) at the end.


                  now it is working.


                  onblur="$s(this, initCap($v('P31_PROJETO_CLIENTE')));"