WordPress.org

Forums

SpeakUp! Email Petitions
[resolved] [closed] Require other fields (7 posts)

  1. michaelrabkin
    Member
    Posted 2 years ago #

    I need to require that petition signers enter their full address - not just name and email address. How do I do that?

    http://wordpress.org/extend/plugins/speakup-email-petitions/

  2. Kreg
    Member
    Plugin Author

    Posted 2 years ago #

    To make the other fields required, you will need to edit the relevant JavaScript files -- /js/public.js for the shortcode form and /js/widget.js for the widget. You can use the required check for the last name field as a model for the other fields you want to make required (the following begins on line 41 in public.js):

    if ( lastname === '' ) {
    	$( '#dk-speakup-last-name-' + id ).addClass( 'dk-speakup-error' );
    	errors ++;
    }

    To make the street field required, you would just duplicate that bit of code and change the variabales and field ids as needed:

    if ( street === '' ) {
    	$( '#dk-speakup-street-' + id ).addClass( 'dk-speakup-error' );
    	errors ++;
    }

    Keep following this model for any other fields you want to make required.

  3. afcoms
    Member
    Posted 2 years ago #

    Hi Kreg,

    That works fine but I am wondering how can I add the * to show that field is mandatory?

    Thanks for your help!

  4. Kreg
    Member
    Plugin Author

    Posted 2 years ago #

    The asterisks are added by a CSS class named "required" which is added to the field labels.

    For the shortcode form, you'll need to edit /includes/emailpetition.php. Add class="required" to the labels of each required field. The HTML output for that form begins on line 33. So, if you are making the Street field required, to add the asterisk you would change line 56 from this:

    <label for="dk-speakup-street-' . $petition->id . '">' . __( 'Street', 'dk_speakup' ) . '</label>

    to this:

    <label class="required" for="dk-speakup-street-' . $petition->id . '">' . __( 'Street', 'dk_speakup' ) . '</label>

    and so on with the other label tags.

    To make these changes to the widget form, you'll need to edit /includes/widget.php. The form output in that file begins around line 175.

  5. afcoms
    Member
    Posted 2 years ago #

    Thanks a lot!

  6. Gigih Wahyudi
    Member
    Posted 2 years ago #

    Hi, Kreg

    I have a question for you. How can i add dropdown list for city/country field and how to make that automatic ? I mean like auto filing names of a city if the country name is given from dropdown list.

    Thanks for your help

  7. @Gigih Wahyudi Rather than piping into a 5 month old resolved thread that is not related to your problem please create your own instead.

    http://wordpress.org/support/plugin/speakup-email-petitions#postform

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • SpeakUp! Email Petitions
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic