WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Resetting Watermarks After Submission (7 posts)

  1. S. Wyatt Young
    Member
    Posted 1 year ago #

    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/

  2. S. Wyatt Young
    Member
    Posted 1 year ago #

    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!

  3. erin814
    Member
    Posted 1 year ago #

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

  4. happynuclear
    Member
    Posted 1 year ago #

    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.

  5. S. Wyatt Young
    Member
    Posted 1 year ago #

    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

  6. erin814
    Member
    Posted 1 year ago #

    Hi,

    happynuclear's solution worked! Thanks for the help!

    Erin

  7. nadinecamille
    Member
    Posted 1 year ago #

    Thanks for this :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic