I need strings to be transformed, having the first letter uppercase, and all the rest lowercase, to store in my database.
For example, the user inputs
name="john";
And I need it to be transformed into
name="John"; 
I need strings to be transformed, having the first letter uppercase, and all the rest lowercase, to store in my database.
For example, the user inputs
name="john";
And I need it to be transformed into
name="John"; 
 
    
    This is a simple script that will allow you to do this.
<input type="text" id="name" onblur="capitalize(this.id)" value="" autofocus>
<script>
    function capitalize(id)
    {
        var text = document.getElementById(id).value; //get the text
        var firstL = text.slice(0,1).toUpperCase(); //get the first character and make it Uppercase
        var rest = text.slice(1).toLowerCase(); //get the rest of the string and make it Lowercase
        var text = firstL.concat(rest); //create the new text store it
        document.getElementById(id).value = text; //set the value of the field
    }
</script>
The onblur event could be changed with a different event such as onkeyup for more immediate results.
