the javascript validation on the table does not work

advertisements

I've read through many posts, and tried various options, but my validation check on my JavaScript doesn't seem to be running.

I used this post to try and write a validation check to see if the entered zip code is one one delivered to, but when I run it nothing happens and neither alert shows up. Any help is appreciated.

This is the JavaScript I was using:

    <script type="text/javascript">
function validateZip() {
  var zipCode = $("#zipCode").val();
  var acceptableZipCodes = ["78205","72215","78212",];

if( $.inArray( zipCode, acceptableZipCodes)){
  alert("Yes, we can help!");
    }else{
  alert("Sorry, we don't deliever to your area yet.");
}
}
</script>

This is the form

<form name="zipForm" onsubmit="return(validateForm(zipCode))">
  <input type="text" id="zipCode" name="zipCode">
    <input id="user_info" type="submit">
</form>


function validateZip() {
  var zipCode = document.zipForm.zipCode.value;
  var acceptableZipCodes = ["78205","72215","78212",];

  for (i = 0; i < cars.acceptableZipCodes.length; i++) {
    if(acceptableZipCodes[i] == zipCode{
     alert("Yes, we can help!");
    }else{
     alert("Sorry, we don't deliever to your area yet.");
    }
  }
}