knackforge
April 24, 2013
HTML 5 has been encompassed with many novel attributes, one of which is the Placeholders. The Placeholder attribute displays text in the input field till it is focused and then hides the text on click. These Placeholders play a momentous role in offering visual information about the field. A general place where I prefer to add Placeholders is template.php in your theme.
Replace theme_name with your theme's name and form_id with the unique identifier associated with your form. The above piece of code will add Placeholders to the field your_field (replace this with your field's name) with the given text.
But one requirement which has made me think a lot in the recent past was to add Placeholders to captcha's input field. I did follow the above-mentioned approach to add the Placeholders, but I failed instantly on each attempt. On debugging I found that the captcha's Placeholder was overridden by the captcha module's functions. Instead of hacking the whole core and getting my work done, I insisted to go with a simple workaround.
The #after-build took care of my work to replace the Placeholder in the captcha input field. With this piece of code, even you can save tons of time as I did.
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!