Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] Resetting Watermarks After Submission

  • Resolved S. Wyatt Young

    (@swyattyoung)


    Does anyone know if it’s possible to reset the watermarks after submission? I’m currently using the watermarks as a means to label each of the input fields, and it works great, except after the submission: the form is left looking creepily naked.

    Is there currently a way to do this through Additional Settings? If not, is there a small bit of code I can tweak until Mr. Miyoshi has time to add a way to do this through additional settings? Any help is truly appreciated!

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter S. Wyatt Young

    (@swyattyoung)

    To anyone looking to do this, I’ve figured out a rather simple solution. Simply add this action hook to the “Additional Settings” of your form:

    on_sent_ok: "$('.wpcf7-use-title-as-watermark').each(function(i,n){$(n).val($(n).attr('title')).addClass('watermark');});"

    That’ll take care of it!

    Thank you! This works great. Do you know how I would do this for my reset button also?

    erin814, I added this functionality to a reset button by adding a reset button in the form code like:

    <input class="wpcf7-reset" type="reset" value="Clear form">

    Then in the main.js file attached to all my pages, used this:

    $('.wpcf7-reset').click(function(event) {
        event.preventDefault();
        $('.wpcf7-form')[0].reset();
        $('.wpcf7-use-title-as-watermark').each(function(i,n){
            $(n).val($(n).attr('title')).addClass('watermark');
        });
    });

    Of course, I haven’t tested the form yet, so hopefully it didn’t wreck anything, but it might help you.

    Thread Starter S. Wyatt Young

    (@swyattyoung)

    erin814,

    If happynuclear’s solution didn’t work for you, please let me know, and provide me with a link to the form in question. I’d be happy to take a look and let you know if I can find something that might be simpler than dabbling in JavaScript.

    Best Regards,
    Wyatt

    Hi,

    happynuclear’s solution worked! Thanks for the help!

    Erin

    nodynu

    (@nadinecamille)

    Thanks for this 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Contact Form 7] Resetting Watermarks After Submission’ is closed to new replies.