$("form").submit(function () {
if ($.inArray($("input:first").val().toUpperCase(), ["UNITED STATES", "USA", "AMERICA"]) > -1) {
//function here
});
<div class="answers">"UNITED STATES", "USA", "AMERICA"</div>
$("form").submit(function () {
if ($.inArray($("input:first").val().toUpperCase(), [$(".answers").html()]) > -1) {
//function here
});
Within the div with the class answers I have the results I need to validate. When I use jquery function .html the results print out fine, but when it validates it needs to validate the whole sentence : “UNITED STATES”, “USA”, “AMERICA” not every answer on its own like it does on the first function. How can I make this work?
Use Split to turn your string of answers into an array.
Will probably work better if the answers are not spaced out, e.g. AMERICA,USA not AMERICA, USA