WordPress.org

Ready to get started?Download WordPress

Forums

Participants Database
[resolved] Set Required Fields Dynamically (4 posts)

  1. kaepora
    Member
    Posted 1 year ago #

    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/

  2. xnau
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. xnau
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. kaepora
    Member
    Posted 1 year ago #

    OK, no problem, thanks for the help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic