I am having some list of pincodes and i want to not to allow checkout for that pincodes if user enters that in the billing or shipping form.

Please let me know.


  • Do you mean zip code / post code? – Kristof at Fooman Sep 10 '14 at 5:02
  • @Fooman yes it is zipcode or postcodes – Pradeep Sanku Sep 10 '14 at 5:41

I have previously solved the same problem by having an associative array of countries and regular expressions of valid ZIP codes within a snippet of JavaScript (with jQuery) on the check-out page. The check-out button starts out disabled on load, so that whenever the value of the ZIP code field changes and the entered value adheres to the pattern of the associated country, the button will be enabled. Otherwise, some animation magic will show the customer that the ZIP code is improperly formatted.

I've done the above for a client in the Netherlands, for example. The valid ZIP code format for the Netherlands is 1111 AA, although the numbers and letters are often written together as well and the ZIP code is just as clear when the letters are lowercase. Knowing this, the validation pattern for this country would be ^\d{4} ?[a-zA-Z]{2}$.

If you are concerned about clients having JavaScript disabled, you could write a module with an event observer that intercepts the payment, validates the payment form's contents, and avoids processing/cancels the order if it's not valid. That's a lot of trouble you might not want to go through, however. In the rare case that somebody has JavaScript disabled nowadays combined with the relatively small chances that somebody is going to enter an invalid ZIP code, you can always notify the customer afterwards and cancel the order.

It's a matter of what you want and need, really.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.