Home > database >  Zip code validation to match City and State
Zip code validation to match City and State

Time:08-04

Hi I have a registration form, and on the address details we require the user to input it's State, City and Zipcode.

My problem is I need to verify the Zipcode if it is the correct Zipcode on the Users State and City.

Example.

If user put's Minnesota (State), Bloomington (City) so if user puts 55437 it should be a valid zipcode. But the tricky part is that some City have multiple Zipcodes so I need to have a data for all of the Zipcode available on that City.

I tried google api geocoding but the return from the API is not consistent. Can anyone suggest on what API or package that is best for this? or Some data where I can store on my DB so that I'll have reference for all the City and Zipcodes.

CodePudding user response:

You can use this data or maybe search for another free zipcode resource. Hope this helps.

https://github.com/midwire/free_zipcode_data

CodePudding user response:

You could use https://www.zipcodeapi.com/. This call https://www.zipcodeapi.com/API#locToZips gives you possible zip codes for a city. There is a free version and a low cost version.

  • Related