: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
<title>Autocomplete - lightweight open-source autocomplete library</title>
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width">
<script src="./autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="./autocomplete.css">
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
background: linear-gradient(-77deg, transparent 95%, rgba(255, 255, 255, 0.23) 15%),
linear-gradient(-77deg, transparent 90%, rgba(255, 255, 255, 0.18) 10%),
linear-gradient(-77deg, transparent 85%, rgba(255, 255, 255, 0.1) 10%),
font: 14px/18px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif
@media (max-width: 800px) {
::-webkit-input-placeholder {
font: 13px/20px 'Lucida Sans Unicode', sans-serif;
padding: 5px 9px 4px 9px;
border: 1px solid #2da5da;
-webkit-appearance: none;
input[type="text"]:focus {
@media (max-width: 600px) {
font: bold 38px/38px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
font: 15px/24px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
@media (max-width: 600px) {
font: 11px/17px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
border: 1px solid rgba(255, 255, 255, 0.8);
box-shadow: rgba(0,0,0,0.3) 0 0 2px;
@media (max-width: 600px) {
text-shadow: 0 1px 1px rgba(0,0,0,0.4)
@media (max-width: 600px) {
font: 18px/30px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
border-bottom: 1px dotted white;
font: 15px/30px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
text-decoration: underline;
font-weight: bold!important;
@media (max-width: 600px) {
<h1 class="text-shadow">Autocomplete</h1>
<h2 class="text-shadow">Blazing fast and lightweight autocomplete library without dependencies. 1KB gzipped.</h2>
<span class="label">Demo</span>
<input type="text" id="testinput" placeholder="Type 'a'" />
<div class="headline text-shadow">Features</div>
<div>Load data with AJAX</div>
<div>Open-Source & Free</div>
<div class="headline links text-shadow"></div>
<a class="link" href="https://github.com/kraaden/autocomplete">Getting Started</a>
<a class="link" href="https://github.com/kraaden/autocomplete">Download</a>
<a class="link" href="https://github.com/kraaden/autocomplete/issues">Issue Tracker</a>
<a class="link" href="https://www.npmjs.com/package/autocompleter">NPM Package</a>
var countries = ['Afghanistan', 'Albania', 'Algeria', 'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bangladesh', 'Belarus', 'Belgium', 'Bolivia', 'Brazil', 'Bulgaria', 'Cameroon', 'Canada', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombia', 'Denmark', 'Dominica', 'Dominican Republic', 'Ecuador', 'Finland', 'France', 'Georgia', 'Germany', 'Gibraltar', 'Greece', 'Greenland', 'Guadeloupe', 'Guatemala', 'Guyana', 'Haiti', 'Iceland', 'India', 'Indonesia', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jersey', 'Jordan', 'Kazakhstan', 'Kenya', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Mauritius', 'Mayotte', 'Mexico', 'Moldova', 'Norway', 'Palau', 'Paraguay', 'Poland', 'Portugal', 'Romania', 'Saint Helena', 'Saint Pierre and Miquelon', 'South Africa', 'South Georgia', 'South Korea', 'Spain', 'Sweden', 'Swaziland', 'Switzerland', 'United Kingdom', 'United States'];
var continents = ["Africa", "Europe", "America", "Australia", "Asia", "Antarctica"];
var conts = continents.map(function(n) { return { label: n, group: "Continents" }});
var items = countries.map(function (n) { return { label: n, group: "Countries" }}).concat(conts);
var allowedChars = new RegExp(/^[a-zA-Z\s]+$/)
function charsAllowed(value) {
return allowedChars.test(value);
input: document.getElementById('testinput'),
onSelect: function (item, inputfield) {
inputfield.value = item.label
fetch: function (text, callback) {
var match = text.toLowerCase();
callback(items.filter(function(n) { return n.label.toLowerCase().indexOf(match) !== -1; }));
render: function(item, value) {
var itemElement = document.createElement("div");
if (charsAllowed(value)) {
var regex = new RegExp(value, 'gi');
var inner = item.label.replace(regex, function(match) { return "<strong>" + match + "</strong>" });
itemElement.innerHTML = inner;
itemElement.textContent = item.label;
emptyMsg: "No countries found",
customize: function(input, inputRect, container, maxHeight) {
container.style.top = "";
container.style.bottom = (window.innerHeight - inputRect.bottom + input.offsetHeight) + "px";
container.style.maxHeight = "140px";
document.querySelector("input").focus();