Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Java script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Java script

    Using Alpha5 v10.5.
    I am aware of the java script code: data = date.toUpperCase() for client side formatting.
    This capitalizes every letter. Is there java script code to capitalize only the first letter of each word and make the other letters of the word lower case. I can't find anything like this.

    Thanks,

    #2
    Re: Java script

    Maybe this helps

    Comment


      #3
      Re: Java script

      Thanks Gary,
      This is what I entered into the Client Side Properties>Format Definition -

      function toTitleCase(str)
      {
      return str.replace(/\w\s*/g, function(txt) {return txt.charAt
      (0).toUpperCase() + txt.substr(1).toLowerCase();});
      }


      I also tried:


      String.prototype.toProperCase = function () {
      return this.replace(/\w\s*/g, function(txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
      }


      I tried them with the String radio button checked and the Java Script radio button checked, parsed in and parsed out.
      The display in the grid is properly changed, but the sql database entry is not changed, the words typed in the grid
      are saved to the db just as it was typed, without any changes.

      Any further ideas would be appreciated. I'm actually surprised I was able to achieve getting the display changed.
      Thanks for the help you've given so far.

      John

      Comment


        #4
        Re: Java script

        Update, not working at all. I had display format set, and that was formatting the display, not the java script.
        At least I am getting a good laugh out of it.

        Comment


          #5
          Re: Java script

          John,
          In the "Client Side Properties" set to Custom then set "Format definition" to:

          data = data.replace(/\w+/g,
          function(w){return w[0].toUpperCase() + w.slice(1).toLowerCase();});


          It is not all that sophisticated but may be better than nothing.

          Isn't it amazing how you can waste 2 hours....
          Last edited by Garry Flanigan; 09-29-2011, 03:37 AM.

          Comment


            #6
            Re: Java script

            Thanks for sticking with me. I had no joy with your last suggestion but it gave me something to work with. I finally got it going (left a lot of nose on the grindstone). I hope syntactically it is correct because it seems to work and I don't want something else to break if it is incorrect. I removed your square brackets around the zero and some other changes. This is what I ended up with, I put it in the Parse Out window only:

            data = data.replace(/\w+/g,
            function(w){return w.charAt(0).toUpperCase() + w.substr(1).toLowerCase() ;});


            Thanks,
            John

            Comment


              #7
              Re: Java script

              Funny you should post this. I am just working on this myself. Here is what I have:
              this.value = this.value.charAt(0).toUpperCase()+this.value.substring(1,this.value.length);
              Put this on the OnBlur event of the field.
              Jay
              Jay Talbott
              Lexington, KY

              Comment


                #8
                Re: Java script

                Jay,
                I put it into the OnBlur event. It only changes the first character of the first word to UPPER. Other capitalized letters in the middle of other words are not affected.

                If you change your code to:
                this.value = this.value.charAt(0).toUpperCase()+this.value.substring(1).toLowerCase();

                it will capitalize the first letter of the first word and change all other letters in the string(even capital letters in the
                middle of a word) to Lower Case. This is what I experienced by trying several different changes to the code.

                What I wanted to accomplish is to capitalize the first letter of each word and make all other letters in each individual word lower case. Your modified code below does that.


                this.value = this.value.replace(/\w+/g,
                function(w){return w.charAt(0).toUpperCase() + w.substr(1).toLowerCase();});


                Thanks,
                John

                Comment


                  #9
                  Re: Java script

                  Put this function in your "Javascript Functions" section:

                  function toTitleCase(txt) {
                  var i, str, lowers, uppers;
                  str = txt.replace(/\w\S*/g, function(txt) {
                  return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
                  });

                  // Certain minor words should be left lowercase unless
                  // they are the first or last words in the string
                  lowers = ['A', 'An', 'The', 'And', 'But', 'Or', 'For', 'Nor', 'As', 'At',
                  'By', 'For', 'From', 'In', 'Into', 'Near', 'Of', 'On', 'Onto', 'To', 'With'];
                  for (i = 0; i < lowers.length; i++)
                  str = str.replace(new RegExp('\\s' + lowers[i] + '\\s', 'g'),
                  function(txt) {
                  return txt.toLowerCase();
                  });

                  // Certain words such as initialisms or acronyms should be left uppercase
                  uppers = ['Id'];
                  for (i = 0; i < uppers.length; i++)
                  str = str.replace(new RegExp('\\b' + uppers[i] + '\\b', 'g'),
                  uppers[i].toUpperCase());

                  return str;
                  }
                  Put this in the onBlur event:
                  this.value = toTitleCase(this.value);
                  The function does not capitalize all words. For example, "this is a test" becomes "This Is a Test". The code was tested and worked fine in v11.
                  Last edited by Garry Flanigan; 10-02-2011, 08:14 PM. Reason: clarification

                  Comment


                    #10
                    Re: Java script

                    Thank you Garry,
                    I'm using A5v10.5
                    I put the function in the, Grid>Properties>Javascript-Other section>JavaScript function declarations

                    and called it from the Fields>Javascript>OnBlur, it worked like a charm.
                    "The Drinks are on the House"---Brian Flanigan/Cocktails and Dreams. (I added 'Are' to the list)

                    I don't want to spook you but, what Java code would strip out all leading and trailing spaces, like an AllTrim(). And where would you put it?

                    Thanks,
                    John

                    Comment


                      #11
                      Re: Java script

                      John,
                      Take a look at http://support.alphasoftware.com/Wha...0/NewInV10.htm
                      You will see here the Alpha javascript library functions, which includes trim, ltrim and rtrim.
                      So if for your field in the grid properties you use "Client side formatting" and define some "Custom" code :

                      data = $u.s.lTrim(data)

                      you will get your input value modified with ltrim.

                      There is also a change case function:

                      $u.s.changeCase(STRING as string, TYPE as string)
                      Change the case of a string. Types can be:

                      "u" - upper
                      "l" - lower
                      "fu" - first character upper
                      "furl" - first character upper, lowercase the rest
                      "wfu" - first character of each word upper
                      "wfurl" - first character of each word upper, lowercase the rest

                      However what was done previously with toTitleCase() is a better solution IMHO for that issue.

                      If you want to use the same method as toTitleCase as outlined in my earlier post then the 3 functions (trim, ltrim, rtrim) are:

                      function trim(txt) {
                      return txt.replace(/^\s+|\s+$/g,"");
                      }

                      function ltrim(txt) {
                      return txt.replace(/^\s+/,"");
                      }


                      function rtrim(txt) {
                      return txt.replace(/\s+$/,"");
                      }
                      Last edited by Garry Flanigan; 10-03-2011, 10:32 PM. Reason: added udf's

                      Comment


                        #12
                        Re: Java script

                        This is getting crazier than Starbucks, there seems to be a thousand options for using Java, or maybe they just refer to the same thing with different names in different places.
                        Alpha5 JavaScript
                        JavaScript function
                        Inline JavaScript
                        When you make a Javascript function declaration in the Grid>Properties, do you use Alpha5 JavaScript Library code or a different javascript code, and if you make a Format Definition using JavaScript in the Grid>Fields>Client Side Properties, which javascript code flavor would go here?
                        Does the inline javascript take the A5 javascript library code or different javascript. I'm getting over caffeinated.

                        Where is the A5 javascript library intended to be used, in Grid>Fields>Client Side Properties>Format Definition, or within Grid>Properties>Javascript other>javascript function declaration?
                        Since JavaScript flavors play such a large part in Alpha5, a white paper focusing on the topic explaining which flavor to use where and why could be very helpful.

                        Anyway,
                        Gary,
                        Thanks again. What my question was meant to ask was, how to incorporate into your original "ofTitleCase" function, additional code to strip out leading and trailing spaces and characters.
                        This is what I did, declare another Grid>Properties> Javascript-Other>JavaScript function declaration, and called it from the field Onblur event. The new function strips out from the field input all leading and trailing spaces and other characters specified.
                        The code below will strip out: spaces, -, $

                        Code:
                        function trim(txt){return txt.txt=($u.s.aTrim(txt,' -$'));}

                        The Onblur event uses Inline Javascript to call the function like this:
                        this.value = trim(this.value);

                        Does anyone see any syntax errors? The whole thing seems to work perfectly.
                        The Onblur event also calls Gary's code from his 10-2-11 post, function toTitleCase, both functions execute and complete the job required.

                        John

                        Comment


                          #13
                          Re: Java script

                          I've been reading this string and wow thank you for the answer Garry M Flanigan. I tried it in my application and it works great.

                          Comment

                          Working...
                          X