jQuery UI & Autocomplete: Accent folding

This entry is part 3 of 7 in the series jQuery UI Autocomplete

jQuery UI Autocomplete – Accent folding

The autocomplete field uses a custom source option which will match results that have accented characters even when the text field doesn’t contain accented characters.

However if the you type in accented characters in the text field it is smart enough not to show results that aren’t accented.

Try typing “Jo” to see “John” and “Jörn”, then type “Jö” to see only “Jörn”.

<!doctype html>
<html lang='en'>
    <meta charset='utf-8'>
    <title>jQuery UI Autocomplete - Accent folding</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
        $(function () {
            var names = [ 'Jörn Zaefferer', 'Scott González', 'John Resig' ];

            var accentMap = {
                'á': 'a',
                'ö': 'o'
            var normalize = function (term) {
                var ret = '';
                for (var i = 0; i < term.length; i++) {
                    ret += accentMap[ term.charAt(i) ] || term.charAt(i);
                return ret;

                source: function (request, response) {
                    var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), 'i');
                    response($.grep(names, function (value) {
                        value = value.label || value.value || value;
                        return matcher.test(value) || matcher.test(normalize(value));

<div class='ui-widget'>
        <label for='developer'>Developer: </label>
        <input id='developer'>

Try The Code
Series Navigation<< jQuery UI & Autocomplete: Scrollable results
jQuery UI & Autocomplete: Combo box >>