WordPress.org

Ready to get started?Download WordPress

Forums

comment form (2 posts)

  1. stiwdio
    Member
    Posted 1 year ago #

    Hi

    I'm trying to input an initial value and clear it when clicked;

    here is the code taken from the includes comment-template.php

    'author' => '<p class="comment-form-author">' . '<label for="author">' . __( '' ) . ( $req ? ' <span class="required"></span>' : '' ) . '</label> ' .
    		            '<input id="author" name="author" type="text" size="24" /></p>',

    however if i add - onclick="this.value=''" i get the parse error below;

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '

    Any help gratefully appreciated;

  2. bcworkz
    Member
    Posted 1 year ago #

    You are using single quotes to define a string fragment, so any single quotes that appear within the fragment need to be escaped with a backslash:
    '<input id="author" name="author" type="text" size="24" onclick="this.value=\'\';" /></p>'

Topic Closed

This topic has been closed to new replies.

About this Topic