As the title says, I need a solution for also working with umlauts like ö, Ö, ä, Ä, ü, Ü and ß. The following script capitalizes each first letter, but has problems with umlauts like the ones stated above. The output of the script is like the following:
- Corey Jones
- Corey.Jones
- Corey-Jones
- Corey,Jones
- Corey/Jones
- Corey-Jones
and so on. This is just fine! But when I want to use umlauts, the output is like:
- CöRey JöNes
- öKan üSal
Every umlaut gets to lowercase, even if it's the first letter. I just want them to fit in the same as the regular alphabet. My content type is set to utf-8 and the document saved in utf-8 w/o BOM. I already tried to add these umlauts to the regex pattern, but neither of them worked.
$(document).ready(function() {
$('.check').change(function() {
if ($('.check:checked').length) {
$('#submit').removeAttr('disabled');
} else {
$('#submit').attr('disabled', 'disabled');
}
});
$.fn.capitalize = function() {
$.each(this, function() {
this.value = this.value.replace(/\b[a-z]/gi, function($0) {
return $0.toUpperCase();
});
this.value = this.value.replace(/@([a-z])([^.]*\.[a-z])/gi, function($0, $1) {
console.info(arguments);
return '@' + $0.toUpperCase() + $1.toLowerCase();
});
});
}
$("#vname").keyup(function() {
$(this).capitalize();
}).capitalize();
$("#nname").keyup(function() {
$(this).capitalize();
}).capitalize();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" name="vname" id="vname" placeholder="Vorname" required="required" class="visible" />
<input type="text" name="nname" id="nname" placeholder="Nachname" required="required" class="visible" />