Possible Duplicate Checker


As part of a project I’m working on, I made an input form for people to submit hiking trails to. In effort to combat duplicate trails, I implemented a feature that queries our databases for locations similar to the one that the user has entered. Here’s a gif of it in action:

Jan-13-2017 02-47-01


First, we have a JavaScript function that queries a .php page

On that .php page, we have

Then, we just call our checkLocation(); function when the user moves off the location input box like this

This updates span#already-exists to be blank when there are no like matches or to say ‘These already exist with a similar name: …’ but only when there is something inside the location input box. No need to call it when there’s nothing to check!