8 Replies Latest reply on Feb 4, 2011 11:29 AM by gkaiseril

    Custom Dialog Box Question

    mmrm Level 1

      I have a text input field in a custom dialog box that I want to force uppercase.  How and where do I do that?

       

      Thanks.

        • 1. Re: Custom Dialog Box Question
          gkaiseril MVP & Adobe Community Professional

          You can use the 'toUpperCase' method of the string object.

          • 2. Re: Custom Dialog Box Question
            mmrm Level 1

            Thats what I thought but where does it go?  In what part of the structure?

            • 3. Re: Custom Dialog Box Question
              gkaiseril MVP & Adobe Community Professional

              You put ".to UpperCase()" after any variable that is a string, any string, and field value. A lot will depend upon your code and where in your scirpt you want to make the conversion and whether or not you want to retain the modified string.

               

              // a variable string

              var text = "abcdefg";

              console.println(text);

              var textUpper = text.toUpperCase();

              console.println(textUpper);

              // a string of characters

              console.println('xyz');

              console.println( 'xyz'.toUpperCase() );

              // a field

              console.println(this.getField('TextField').value);

              console.println( this.getField('TextField').value.toUpperCase() );

              // from a response box

              var cResponse = app.response('Enter a text string')
              console.println(cResponse.toUpperCase());

               

              • 4. Re: Custom Dialog Box Question
                mmrm Level 1

                But for a dialog box (execDialog) do I put it in the initialize, validate, or commit section?  That's what I am unsure about and can't seem to get working.  I know in a regular form field I use "event.value = event.value.toUpperCase()" as a custom calculation and it changes to uppercase as you type.  I'm looking for that same functionality in my “edit_text” box in my dialog.

                • 5. Re: Custom Dialog Box Question
                  gkaiseril MVP & Adobe Community Professional

                  Well it very obviously depends upon your code. Since I am in the U.S. Midwest, my crystal ball is full of snow, because I have not had time to shovel it out.

                   

                  You might want to look at the MDC JavaScript 1.5 Reference and the Acrobat JS API Reference. Both are available for free.

                  1 person found this helpful
                  • 6. Re: Custom Dialog Box Question
                    try67 MVP & Adobe Community Professional

                    The question is at which point to do you want the conversion to happen? Each

                    time the user enters a new value (like with a form field format script)? If

                    so, I don't think that's possible.

                    1 person found this helpful
                    • 7. Re: Custom Dialog Box Question
                      mmrm Level 1

                      Yes that what I was hoping for but I think you are right, I don't think its possible.

                      • 8. Re: Custom Dialog Box Question
                        gkaiseril MVP & Adobe Community Professional

                        Since that is your belief, then you should provide some verification that only upper case letters are entered.

                         

                        // get your string value

                        var myString = "xxyyzz";

                        // force to upper case

                        myString =  myString.toUpperCase;

                         

                        Not that until the last line runs, the variable 'myString' is in lower case, only after that line of code is run, does the string become upper case.

                         

                        You should be able to edit your dialog to code to perform this same action.