placeholder text in zend text element

Viewed 13562

I am working on a Zend form application where my form contains text boxes with watermarks.

we can achieve this in HTML by the following code:

<input type="text" placeholder="Search" name="q" />

My question is how to add the placeholder attribute in my input-box using Zend form ?

5 Answers

My solution using jQuery

var elements = ['email', 'password', 'password_confirm'];
$j(elements).each(function(i, elem){
    $j('#' + elem).attr('placeholder', $j('#' + elem + '-label label').text());
    $j('#' + elem + '-label').hide();
    if ($j('#' + elem).hasClass('required-entry')) $j('#' + elem).attr('placeholder', $j('#' + elem).attr('placeholder') + ' *');
});

Related