You can do it using Javascript... this way:
<script type="text/javascript" language="Javascript">
function capitalize(campoFormulario) {
var string = document.getElementById(campoFormulario).value;
if(string.length > 0) {
string = string.toLowerCase();
string = string.split(' ');
for (var i = 0, len = string.length; i < len; i++) {
if(string[i].length > 2) {
string[i] = string[i].charAt(0).toUpperCase() + string[i].slice(1);
};
};
document.getElementById(campoFormulario).value = string.join(' ');
return true;
}
}
</script>
In html, in the Input field identified with id, it will look like this:
<input type="text" name="campo_nome" id="campo_id" onkeyup="capitalize(this.id);">
A single remark: when I put in the javascritp code "if(string[i].length > 2)" I am indicating that I want to capitalize only words that have more than 2 characters... if you prefer change this value, or delete this if.
http://php.net/manual/en/function.ucfirst.php look at my friend
– MarceloBoni
And if it’s José da Silva?
– Bacco
@Bacco, sorry, but laughs a lot here.
– Gato de Schrödinger