Search code examples
phpjqueryvalidationlocationcity

Normalising/Validating user's 'City' input during registration


My problem concerns validating/normalising a user's input for the combination of Country and 'City' during registration. Ideally, I want functionality similar to the OkCupid (http://www.okcupid.com/signup) registration page where this question is asked. Loss of focus on the City input field validates the input somehow, and it is amazingly good at it. I tried a small country town in rural Australia (pop. < 6000) and a random town in Finland, and both were validated correctly and quickly.

Normalising/Validating is important because I would like to normalise the 'City' field of a user-generated event entity to allow matching against users in the same location.

This validation makes sense both from an application logic perspective (I don't want to deal with the 'NYC' = 'New York City' = 'New York, New York' = 'New York' quagmire), and a user perspective (other users understanding a user's location).

I'm using PHP and jQuery if that makes a difference, but any solution at this point is more promising than nothing!

Thanks in advance!

EDIT : Solved! Yahoo provides the PlaceMaker API - free-form location string parsing! 50,000 requests per day limit:

http://developer.yahoo.com/geo/placemaker/


Solution

  • Solved! Yahoo provides the PlaceMaker API - free-form location string parsing! 50,000 requests per day limit:

    http://developer.yahoo.com/geo/placemaker/