Elena Posted June 12, 2014 Report Share Posted June 12, 2014 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. Quote Link to comment Share on other sites More sharing options...
Jan Posted June 19, 2014 Report Share Posted June 19, 2014 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]; } else { if ((nextCap)&&(val[i].match(/^[A-Za-z]+$/))) { nextCap = false; newVal += val[i].toUpperCase(); } else {newVal += val[i];} } } document.getElementById('InsertRecordtext64000').value = newVal; } document.getElementById('caspioform').onsubmit=capitalize; </script> I hope it helps. Quote Link to comment Share on other sites More sharing options...
Elena Posted June 20, 2014 Author Report Share Posted June 20, 2014 Hi there, Many thanks indeed. This helped tremendously. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.