In pure javascript I can use indexOf()
, something like this:
var chaves = ['wmv','3gp','mp4','mp3','avi'];
if(chaves.indexOf("avi") != -1)
{
alert("Ok!");
}
But when it comes to a search field I'm trying this way:
<html>
<body>
<input type="text" id="txt" onblur="verifica()"/>
</body>
<script>
var chaves = ['wmv','3gp','mp4','mp3','avi'];
var item = document.getElementById('txt').value;
function verifica() {
for(var i = 0; i < chaves.length; i++)
{
if(chaves[i].length == item) {
alert("SIM")
} else {
alert("NAO")
}
}
}
</script>
</html>
The worst is that I've done it once and now I do not remember it anymore .. if anyone can help.