Jump to content

Formatting Text Automatically

Recommended Posts

I am sure there is a solution to this simple issue,  because I witnessed (and continue to witness) it first hand in this forum window. I tested the topic title of this forum and noticed that it has the capability to force format texts, i.e. all words are forced to begin with a capital letter.


One of my issues is that, users sometimes type in ALL CAPS or in all lower case. The result is a table with user input information that are inconsistent. Not good when you're trying to capture the information to be placed in a formal document later, such as a report.


How can I automatically format text fields, and text areas to force the result to look like they are properly typed in, such as: Avoidance of ALL CAPS and ALL Lower case, forced caps after period, caps only when it is a noun or acronym.


Any help is appreciated.

Link to comment
Share on other sites

Hello Elena,


I can propose you the JavaScript code that forced caps after period, but I do not know how to save acronyms.

It works for text fields and text areas.

<script type="text/javascript">
function capitalize()
 var text = document.getElementById('InsertRecordtext64000').value; 
 text = text.toLowerCase();
 var newVal = '';
 var val = text.split('');
 var nextCap = true;

 for(var i=0; i < val.length; i++) 
    if (val[i]=='.') 
         nextCap = true;
         newVal += val[i];
        if ((nextCap)&&(val[i].match(/^[A-Za-z]+$/)))
           nextCap = false;
           newVal += val[i].toUpperCase();
          {newVal += val[i];}
 document.getElementById('InsertRecordtext64000').value = newVal; 

I hope it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...