0

The Search form is pretty much a styled version off of the default twenty eleven Wordpress one.

The default text display almost everywhere -- but not in FF 3.6, and probably older IE's. I'm assuming because twenty eleven theme by default uses some CSS3 calls with the search. In any case -- whats the traditional code that works across for form field default text, again??

(I'd prefer to do without PHP, jQuery, JS) -- But ultimately which ever route is solid.

Here is the code within search form:

<?php
/**
 * The template for displaying search forms in Twenty Eleven
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
?>
    <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
        <label for="s" class="assistive-text"><?php _e( 'Search', 'twentyeleven' ); ?></label>
        <input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search, title, author, keyword', 'twentyeleven', 'twentyeleven' ); ?>" />
        <input type="submit" class="submit" name="submit"  id="searchsubmit" value="<?php esc_attr_e( 'Search' ); ?>" />
    </form>

<div id="searchtbtn"><img src="http://mysite.com/wp-content/uploads/2012/03/searchnav_btn.gif" style="margin-left: 292px; margin-top: 60px; max-height: 35px; max-width: 70px; position: absolute;"></div>

1 Answer 1

2

The placeholder attribute <input type="text" placeholder="... is part of HTML5 and if you'd like to have a non-PHP, non-jQuery, non-JavaScript fallback, then you can either just set the default value or style it with a CSS background image.

2
  • Thanks for the response. How do I set a 'default' value? Mar 20, 2012 at 12:19
  • You would specify a value="something" for the input field (e.g. <input type="text" value="Search" .... However since you don't want to use JavaScript, the user would need to delete this text prior to entering their search term. IMO using jQuery to handle this would be the best solution.
    – j08691
    Mar 20, 2012 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.