OpenLayers WFS getFeatureByAttribute

HTML

<script src="http://cdnjs.cloudflare.com/ajax/libs/openlayers/2.11/OpenLayers.js"></script>
<body onload="init()">
    <h1>OpenLayers WFS with getFeatureByAttribute</h1>you can test it with the city names Bendigo, Albury for example (case sensitiv!)
    <br />Name:
    <input type="text" id="cityname" value="Cobram">
    <br>
    <button onclick="select()">Select City</button>
    <div id="map"></div>
</body>

CSS

#map {
    width: 400px;
    height: 600px;
}

JavaScript

var map;
var layer, wms, selectControl;

function init() {
    map = new OpenLayers.Map('map');
    wms = new OpenLayers.Layer.WMS(
        "OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {
        layers: 'basic'
    });

    layer = new OpenLayers.Layer.Vector("WFS", {

        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
            url: "http://demo.opengeo.org/geoserver/wfs",
            featureType: "ne_10m_populated_places",
            featureNS: "http://openstreemap.org"
        })
    });

    map.addLayers([wms, layer]);
    //layer.getFeaturesByAttribute('NAME','Albury');

    map.setCenter(new OpenLayers.LonLat(146.7, -41.8), 6);

    selectControl = new OpenLayers.Control.SelectFeature(map.layers[1], {
        onSelect: onFeatureSelect,
        onUnselect: onFeatureUnselect
    });

    map.addControl(selectControl);
    selectControl.activate();



}

function select() {
    var chosen_city = document.getElementById("cityname").value;
    // console.log(chosen_city);
    var selected_item = layer.getFeaturesByAttribute('NAME', chosen_city);
    //console.log(selected_item);
    if (selected_item) {
        selectControl.select(selected_item[0]);
    } else {
        alert("error");
    }
}

function onPopupClose(evt) {
    selectControl.unselect(selectedFeature);
}

function onFeatureSelect(feature) {
    selectedFeature = feature;
    popup = new OpenLayers.Popup.FramedCloud("chicken",
    feature.geometry.getBounds().getCenterLonLat(),
    new OpenLayers.Size(100, 100),
        "<h2>" + feature.attributes.NAME + "</h2>" + feature.attributes.ADM0NAME,
    null, true, onPopupClose);

    feature.popup = popup;
    //map.addPopup(popup);
    map.addPopup(popup, true);

}

function onFeatureUnselect(feature) {
    map.removePopup(feature.popup);
    feature.popup.destroy();
    feature.popup = null;
}