Try the code below, i haven’t tested it but it should work
function makeUppercase(field) {
var value = field.value, parts = value.split(',');
for(var i in parts) {
if (parts[i].substr(1) == ',') {
parts[i].toUpperCase();
}
}
field.value = parts.join('');
}
the problem with manipulating the whole inserted so far string on each key press is it messes with the cursor position (in at least some, if not all, browsers). e.g. if someone types the following into a text field whose text is being changed as a whole on an ongoing basis (where | represents the text cursor):
123678|
then moves their cursor back once and proceeds to type from then on to try and insert text, this happens (which is veryvery (as in unacceptable imo) anoying):
123|678
1234678|
12346785|
you can start to try and control the cursor position but this is either hard or impossible (at least correctly in all main browsers) – that’s what i found anyway.
so unpleasant issues can easily occur with this kind of thing when the user does other things that just typing sequentially (pasting, cursor position changing, selecting …)