I'm new to jQuery but here is what I'm trying to do.
I have a form with an multi select field named City and Zip,
I'm trying to get the values of this select field and compare it against a list of cities I have, if found any match jQuery will update the value of a hidden text field named city with these values and then submit the form. if no match found they will be redirected to a different website.
Same thing with the Zip codes, it will get the zip codes from the same field and see if it matchs any zip code from the list. if yes then update the zip code hidden field, if no then redirect them to another website.
Here is my code right now and It's not working.
$("#front-form").submit(function(event) {
// Getting the values from the HTML select field
var CityandZip = $("#citynzip").val();
//Comparing the values with the cities list
if (CityandZip === "City 1" || "City 2" || "City 3") {
//Updaing the hidden field and submitting
$("#HiddenCityField").val(CityandZip);
//Comparing the values with the ZIP code list
} else if (CityandZip === "11111" || "11112" || "11113") {
//Updating the hidden ZIP code field
$("#HiddenZipField").val(CityandZip);
} else {
//Redircting to a new site
window.location.href = "http://www. redirecttowebsite.com";
}
});
Any help would be appreciated and thanks in advanced.