inArray - checking for a value in an array

by Bhabani Raju

HTML

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

JavaScript

var registercode = ['vadim', 'thomas', 'tanya'];

   
        var evntcode = $('#code').val();
        if (jQuery.inArray(evntcode, registercode)!='-1') {
            alert(evntcode + ' is in the array!');
        } else {
            alert(evntcode + ' is NOT in the array...');
        }