PHP has a function that does EXACTLY what you’re looking for, ucwords()
. Leave the CSS capitalize
on there, so that the users know it will be auto-capitalized, and then when you’re filtering the input (which you should be doing ANYWAYS, since it’s user input, run it through ucwords()
right before database insertion.