JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
<button type= "submit" id= "SUBMIT" onclick="validate()" value="SUBMIT"> BUTTON</button>
</div>
</body>
JavaScript
var valuePresentInSearchList = false;
$(function() {
$("#SUBMIT").bind("click", function() {
alert('Entered value: '+$("#tags").val() +' Its presence in list: ' + valuePresentInSearchList);
});
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags,
response: function( event, ui ) {
valuePresentInSearchList = false;
jQuery.each( ui.content, function( key, value ) {
for( k in value ) {
// alert( "key is " + [ k ] + ", value is " + value[ k ] );
// CHECK HERE IF INPUT VALUE IS EXACTLTY MATCH
if( value[ k ] ==$("#tags").val())
{
valuePresentInSearchList = true;
}
}
});
}
});
});