Jquery .val() == ** adding multiple possible answers **
javascript, jquery
Solution
Using $.inArray():
if( $.inArray( $("input:first").val().toUpperCase(), [ "UNITED STATES", "USA", "AMERICA" ] ) > -1 ) { ...
Demo: http://jsfiddle.net/4ar2G/
Problem
I achived this by doing the following, but as a newbie to javascript and jquery i want to know if there is any shorter way to add multiple possible values. ``` if ($("input:first").val().toUpperCase() == "UNITED STATES" || $("input:first").val().toUpperCase() == "USA" || $("input:first").val().toUpperCase() == "AMERICA") { $("#check").text("Correct!").show().fadeOut(5000); return true; ``` Like ``` if ($("input:first").val().toUpperCase() == ("UNITED STATES","USA","AMERICA")) { $("#check").text("Correct!").show().fadeOut(5000); return true; ``` by this only validates the last answers in this case AMERICA.