Anyone see where I can amend this JS so not to strip out hypens and
punctation etc..?
function UpperCaseLetters(myField) {
var pattern = /(\w)(\w*)/; // a letter, and then
one, none or more letters
var a = myField.value.split(/\s+/g); // split
the sentence into an array of words
for (i = 0 ; i < a.length ; i ++ ) {
var parts = a[i].match(pattern); // just a temp
variable to store the fragments in.
var firstLetter = parts[1].toUpperCase();
var restOfWord = parts[2].toLowerCase();
a[i] = firstLetter + restOfWord; // re-assign it
back to the array and move on
}
myField.value = a.join(' '); // join it back together
}
basically when I enter the following into a field this : Neil
Robertson-Ravo, its stripping out everything and just leaving Neil, its fine
if all you put in is Neil - then it does capitalize it to NEIL.
I want it to take into account hypens and punctuation should it need to.
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]