I have a form with some text inputs to insert First Name, Last Name of a person, but I want to change the first letter of each word to a Uppercase and I found this solution:
 // The textboxes with this class are modified
 $(".toUpper").change(function () {
        var str = $(this).val();
        str = str.toLowerCase().replace(/\b[a-z]/g, function (letter) {
            return letter.toUpperCase();
        });
        $(this).val(str);
    });
and it works, ("hEllO"=>"Hello", "whAts uP" =>"Whats Up").
The problem occurs when I try to apply this to an accented word, Example:
"gonzález" = "GonzáLez",
"pérez" = "PéRez"
After an accented word there is a Uppercase letter again.
How can I modify the regular expression to avoid this issue?
hope you can help me!! :)
 
     
     
    