I’m trying to create a form that pops-up an error when people insert a specific zip code or range of zip codes.
For example:
If a potential lead fills out a form and enters a Washington state zip code I’d then want an error to pop-up to say we don’t offer the product in that state.
I’ve search Google and Stackoverflow but still haven’t found a working example of code… I’ve seen ones that are similar but not exactly what my example says.
the example I’m looking for could be in javascript or jquery
Considering an input element with the ID of zipCode
We can capture the value of it by doing something like
Considering an array built like…
We can test to see if the value of zipCode is within the array, if it’s not, we’ll return an alert.
Now, we should probably put our code within an event. Let’s use the keyup function, but because we don’t want to check every value, we’ll check on only the 5th keyup.