Support » Everything else WordPress » making default text field value disappear on focus

  • I had had my search field working so that the default text displayed in the field would disappear when the field was clicked. The default text would reappear if the field lost focus.

    Somehow this no longer works. Now the default text is displayed _outside_ the search field. (The search function still works properly, it is just the display of the default text that is no longer working.)

    Here is the code I have in the head of index.php:

    <script type=”text/javascript”>
    function clearText(input){
    if (input.defaultValue==input.value)
    input.value = ”


    <script type=”text/javascript”>
    function restoreText(input){
    if (input.value==”)
    input.value = input.defaultValue


    Here is the code I have in what functions as my (manual) sidebar:

    <span title=”click to open/close”>
    <h3 class=”pointandclick” onClick=”toggleContent(‘mySearchList’)”>search</h3>
    <div id=”mySearchList” style=”display: none; color: #666666″>

      <li id=”search”>
      <label for=”s”><?php _e(‘enter search term’); ?></label>
      <form id=”searchform” method=”get” action=”<?php echo $PHP_SELF; ?>”>
      <input type=”text” name=”s” id=”s” size=”15″ />
      <input type=”submit” name=”submit” value=”<?php _e(‘search’); ?>” />


    Any suggestions most gratefully received!

  • The topic ‘making default text field value disappear on focus’ is closed to new replies.