WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Contact Form 7] clear input labels (5 posts)

  1. Ziggii
    Member
    Posted 4 years ago #

    Is it possible to clear the labels placed in the input field?
    Example, I have an email field, in this field is the word "Email". As soon a visitor clicks on it to enter his email the word (label) should dissappear. Is there a way to create this?

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

  2. digitz
    Member
    Posted 4 years ago #

    This would be a useful option indeed.

  3. Ziggii
    Member
    Posted 4 years ago #

    I have tried this post but can't figure out how to let this work with contactform 7.

  4. emj
    Member
    Posted 4 years ago #

    hmm, I had the same problem and got textboxes working like this:

    a) add this javascript to header.php

    function clearText(field)
    {
    if (field.defaultValue == field.value) field.value = '';
    }

    (thanks http://www.bradino.com/javascript/clear-textfield-default-value-onclick/)

    b) in the contact form 7 plugin folder, edit file /modules/text.php

    c) find line 76
    $html = '<input type="text" name="' . $name . '" value="' . esc_attr( $value ) . '"' . $atts . ' />';

    d) between 'input' and 'type', add:
    onFocus="clearText(this)"

    worked fine for me, bit of a hack tho

    :)

  5. brian7997
    Member
    Posted 4 years ago #

    Dont forget :

    onBlur="restoreText(this)"

    and

    function restoreText(field) {
    	if (field.value == '') field.value = field.defaultValue;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic