PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How do you add custom PHP validation to a gform field?

  1. I want a dropdown that is populated with countries but that has an option at the top 'Please choose...'. How can I validate against this when the field is required but without using javascript. I need to prevent the value 'please choose' from being accepted as a value.

    Any ideas?

    Posted 9 years ago on Wednesday September 8, 2010 | Permalink
  2. You can use Gravity Forms 1.4 beta, and use the Option/Value capabilities. Make the first option "Please Choose..." but don't give it a value. Then make the field required. The field will fail validation because there is no value.

    You would, of course, then have to add values for the countries. You can do this either using the built in interface or the bulk add. In bulk add you separate the option/value with a pipe.


    United Kingdom|UK

    This would then parse and use United Kingdom for the option label and UK for the value.

    1.4 final is getting ready to be released most likely later today.

    Posted 9 years ago on Wednesday September 8, 2010 | Permalink