Title: Set Required Fields Dynamically
Last modified: August 20, 2016

---

# Set Required Fields Dynamically

 *  Resolved [kaepora](https://wordpress.org/support/users/kaepora/)
 * (@kaepora)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/set-required-fields-dynamically/)
 * I’m doing two forms using two templates which is fine (I’ve been browsing you’re
   support threads – lots of info making the plugin extremely customisable!).
 * However I’d like to require a couple of fields in one form/template but not another.
   I saw you could dynamically set the ‘type’ of a field on the **record** template
   from hidden to text using:
    `$this->record->fields['fieldname']->form_element
   = 'text-line'`
 * Can a similar method be used to set the validation property of a field to required
   in the **signup** template, even if it’s not set to be required in the WP backend?
   Something like:
    `$this->fields['fieldname']->validation = 'yes'`
 * I’ll be able to try some things out myself tomorrow, but if you can help that
   would be great!
 * [http://wordpress.org/extend/plugins/participants-database/](http://wordpress.org/extend/plugins/participants-database/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/set-required-fields-dynamically/#post-3607202)
 * kaepora,
 * No, this isn’t possible because the validation happens after the page is submitted(
   server-side) and all the validation settings will be refreshed. Your best bet
   would be to use Javascript…the jquery validation plugin makes this very easy.
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/set-required-fields-dynamically/#post-3607203)
 * It’s easy to add the validation javascript to the template, but you’d probably
   want to include the jquery validation plugin in your theme functions so it goes
   in at the right place.
 *  Thread Starter [kaepora](https://wordpress.org/support/users/kaepora/)
 * (@kaepora)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/set-required-fields-dynamically/#post-3607216)
 * OK, no problem, thanks for the help!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Set Required Fields Dynamically’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

## Tags

 * [on-the-fly](https://wordpress.org/support/topic-tag/on-the-fly/)
 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 3 replies
 * 2 participants
 * Last reply from: [kaepora](https://wordpress.org/support/users/kaepora/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/set-required-fields-dynamically/#post-3607216)
 * Status: resolved