inArray - checking for a value in an array

by Akram kamal

HTML

<input id="name" type="text">
<input id="check" type="button" value="Check">

JavaScript

$(document).ready(function() {
    var names = ['vadim', 'thomas', 'tanya', 'timur', 'eve', 'kate', 'karen', 'peter'];

    $('#check').click(function() {
        var name = $('#name').val();
        if (jQuery.inArray(name, names)!='-1') {
            alert(name + ' is in the array!');
        } else {
            alert(name + ' is NOT in the array...');
        }
    });
});