mardi 25 avril 2017

If and Else Statements Always Output If

I was messing around with a previously existing snippet and ran into an issue. Whenever I try to enter an input that doesn't apply the to If statement it always gives me the If output. Also I was looking to, instead of saying approved, have you sent to a URL, like Google for example, and I'm not sure about a solution for either of the two.

<p>Enter Zip Code </p>
<input id="text_a" type="text"/>
<p id="answer"></p>
<button onclick="myFunction()">Check</button>

<script>
function myFunction()
{
var a=document.getElementById("text_a").value;

if (a=="02035","02048","02067")
  {
document.getElementById("answer").innerHTML="Approved";
  }
else
  {
document.getElementById("answer").innerHTML="Our service currently isn't available in your area! Try again soon!";
  }
}
</script>

Aucun commentaire:

Enregistrer un commentaire