How to stop ALL CAPS? 
Author Message
 How to stop ALL CAPS?

I have a form with a text field that the user is to enter a description of
an item.  Sometimes a user --in spite of being told not to-- will enter the
information in ALL CAPS or near so.  Using Perl or JavaScript, how can I
filter their input to get rid of the all caps input.

It is OK if the user capitalizes each word, but words entered without
capitalization should stay that way.  Single, double, and triple letter
words all caps would be considered OK, but anything longer should be reduced
to first-letter caps only.  Exceptions would need be made for common words
(such as A, AS, OR, TO, ALL, AND, THE), which should be all lowercase.
Caps mixed with numbers would be OK.
Punctuation may need to taken into consideration.

Any suggestions on how to handle this?
Would regular expressions be a good approach?  How exactly?



Sun, 09 Feb 2003 03:00:00 GMT  
 How to stop ALL CAPS?


: I have a form with a text field that the user is to enter a
: description of an item.  Sometimes a user --in spite of being told not
: to--

Users suck. :-(

:      will enter the information in ALL CAPS or near so.  Using Perl or
: JavaScript, how can I filter their input to get rid of the all caps
: input.

Do you want to detect it or correct it?  You could detect it with

    # if more than half of the characters are uppercase
    if ( $field =~ tr/A-Z// > 0.5 * length($field) ) {
        ...;  # book 'im, Dan-o
    }

You could correct it with

    $field = "PERL";
    $field =~ s/\b(.)(.*?)\b/$1\L$2/g;  # :-/

Greg
--
Facts do not cease to exist because they are ignored.
    -- Aldous Huxley



Mon, 10 Feb 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Invalid Alias

2. Reading text files where same word is spelled wtih all caps or no caps

3. Prevent Stop Service from stopping Perl Script on NT

4. Stop CGI program when STOP button in WebBrouser is downed

5. term::cap

6. How to check for ALL caps in aline

7. How to I changs first letter of all words in caps and remaining in small

8. ALL CAPS-->Mixed case converter?

9. WANTED: perl script for gopher .cap directory to .names file

10. Need help changing form input to leading caps on certain entries

 

 
Powered by phpBB® Forum Software