I need to make sure all my fields are written with what we are calling Correct Case. It means first letter upper, and all other letters on lowercase.
I have the following code that is being executed on the keyupevent of some text input fields. This code works, but does not treat cases where the word separator is a period :
var e = window.event;
var words = e.srcElement.value.split(' ');
var len = 0;
for (i=0; i< words.length; i++)
dst += words[i].charAt(0).toUpperCase() + words[i].substring(1,words[i].length).toLowerCase();
len += words[i].length;
if ( (i+1) != words.length) //do not add spaces to last word
dst += ' ';
e.srcElement.value = dst;
I tired using regular expressions for my split, but I'm not very familiar with regular expressions and it didn't work.