WordPress.org

Ready to get started?Download WordPress

Forums

Inline labels in comment form (jquery/ ajax) (3 posts)

  1. kloooty
    Member
    Posted 3 years ago #

    Hello there,

    I want my comment form to use inline labels just like with this jQuery:

    http://fuelyourcoding.com/scripts/infield/

    ... thing is I can't seem to get this to work in my wordpress theme. Is there a wordpress example making inline labels possible?

    thanks in advance,
    klooty

  2. kloooty
    Member
    Posted 3 years ago #

    No one got a clue?
    I got this kinda working in the search box using only javascript:

    <input type="text" class="f_search" value="Search the blog" onfocus="if (this.value == 'Search the blog') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search the blog';}" />

    But this doesn't work within the comments fields. no idea why, I guess because of the php? this is how i do it (in comments.php):

    $args = array( 'fields' => apply_filters( 'comment_form_default_fields', array(
        'author' => '<p class="comment-form-author">' .
                    '<label for="author">' . __( '' ) . '</label> ' .
                    ( $req ? '' : '' ) .
                    '<input id="author" name="author" type="text" value="' .
                    'YOUR NAME' . '" size="30" tabindex="1"' . $aria_req . ' onfocus="if(this.value=="YOUR NAME"){this.value="";}"' . ' />' .

    This would be ok if it worked. Though I'd like it better if i could also give this value text a different style using css etc.

    any clues?

  3. kloooty
    Member
    Posted 3 years ago #

    my mistake, i used " instead of \'.

    This way it works:

    $args = array( 'fields' => apply_filters( 'comment_form_default_fields', array(
        'author' => '<p class="comment-form-author">' .
                    '<label for="author">' . __( '' ) . '</label> ' .
                    ( $req ? '' : '' ) .
                    '<input id="author" name="author" type="text" value="' .
                    'YOUR NAME' . '" size="30" tabindex="1"' . $aria_req . ' onfocus="if(this.value==\'YOUR NAME\'){this.value=\'\';}"' . 'onblur="if(this.value==\'\'){this.value=\'YOUR NAME\';}"' . ' />' .

    Still, I would prefer a jQuery variant so i could change the style. anyone got something for that?

Topic Closed

This topic has been closed to new replies.

About this Topic