Title: Custom Validation
Last modified: December 14, 2017

---

# Custom Validation

 *  [Jonathan Kingsbury](https://wordpress.org/support/users/ridinhighspeeds/)
 * (@ridinhighspeeds)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/custom-validation-12/)
 * We have a field where we ask the user to enter in the City, State that is connected
   to the Google Maps API. Problem is, we have submissions where the user clearly
   didn’t select a location from the drop-down list. The user can enter in Massachusetts(
   as an example), where we need to know what city in Massachusetts (i.e. Boston,
   Massachusetts). To resolve this, I imagine setting up a condition where the first
   letters contain the letters of any of the 50 states would result in an error (
   Please enter a valid City & State). Has anyone written a custom validation to
   not accept certain values in a field?
 * Long story short, an error should appear next to the field if the user entered
   in any of the 50 states in the U.S. The form will accept city/state, but not 
   just a state.
 * Thanks

The topic ‘Custom Validation’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [condition](https://wordpress.org/support/topic-tag/condition/)

 * 0 replies
 * 1 participant
 * Last reply from: [Jonathan Kingsbury](https://wordpress.org/support/users/ridinhighspeeds/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/custom-validation-12/)
 * Status: not resolved