var y=document.forms["form"]["user"].value if (y==null || y=="" ) { alert("Username cannot be Blank"); return false; }; var x = new Array(); x[0] = "bill"; x[1] = "ted"; x[2] = "jim"; for ( keyVar in x ) { if (x==y) { alert("Username Taken"); return false; }; };
How to compare a variable with a JavaScript array, I managed to make an example above, but the second part - the bit that I need, does not work. any ideas?
source share