I would like to normalise the first name of my users when the type it on an input field.
<input type="text" name="firstName">
So, when the user types:
- tommy, it should be corrected to Tommy.
- jean-claude, it should be corrected to Jean-Claude.
Is there a function to do this ?
This is what I tried:
new_str = str.toLowerCase().replace(/\b[a-z]/g, function(txtVal) {
return txtVal.toUpperCase();
});
$('.list-title').text(new_str);
But it doesn't work for the second case.
Thanks for your help.