I don't really like people who write with Caps Lock. In addition the aversion, it defaces the whole application. I am wondering how to prevent users writing all characters with caps lock. I cannot force all text to lowercase due to special names and abbreviations. What logic should I use?
Asked
Active
Viewed 631 times
7
-
8If you dislike capital letters so much, why did you inflict an all-capital-letter question on us ? – High Performance Mark Jun 28 '12 at 11:21
-
I don't think you can, as the algorithm would have to understand all of the special names as and abbreviations that a user might type. It's easy enough to force Capitalization of Titles, or sentence capitalization, but these will break people with particular names (McLaren) or similar. You could use a whitelist of allowed abbreviations, perhaps. – Oliver Jun 28 '12 at 11:22
-
@HighPerformanceMark just for testing :) – quosal Jun 28 '12 at 11:22
3 Answers
10
Politely decline their posts—explaining why—if the number of capital letter exceeds the number of lowercase letters by more than 30, say.
Don't implement this on a FORTRAN forum

Colonel Panic
- 132,665
- 89
- 401
- 465
3
You could check how many upper case characters are in a word, then limit that. Someone above has given the example of names like 'McLaren', this way would allow that. the down side is, if you put the maximum on 3, 'LOL' would stil be possible. The way to go would be to take the length of the word 'McLaren' would be 7 then cap it on a percentage like 20%, this enables longer words to have more uppercase characters, but not be all caps. (nothing will completely prevent it, but this will make it harder for them.)
Fun fact, today is international caps-lock day. :)

Viezevingertjes
- 1,507
- 1
- 13
- 25
0
keypress: function(e) {
var ev = e ? e : window.event;
if (!ev) {
return;
}
var targ = ev.target ? ev.target : ev.srcElement;
// get key pressed
var which = -1;
if (ev.which) {
which = ev.which;
} else if (ev.keyCode) {
which = ev.keyCode;
}
// get shift status
var shift_status = false;
if (ev.shiftKey) {
shift_status = ev.shiftKey;
} else if (ev.modifiers) {
shift_status = !!(ev.modifiers & 4);
}
// At this point, you have the ASCII code in "which",
// and shift_status is true if the shift key is pressed
}

swapnesh
- 26,318
- 22
- 94
- 126