You could duplicate the webpart (because you'll be making a change to a base Kentico webpart) and make one of these simple changes:
- add the
placeholder attribute to the TextBox (if using HTML5)
- You could make your copied webpart ascx control like so:
<script type="text/javascript">
function setPlaceholdertext() {
var oText = document.getElementById('clientIDOfTextBox1');
if (oText != null) {
// if taking focus away from textbox check to see if any text was entered, if not set the text
if (oText.value.length < 1) {
oText.value = 'Search Text';
}
}
}
function clearPlaceholdertext() {
var oText = document.getElementById('clientIDOfTextBox1');
if (oText != null) {
if (oText.value == 'Search Text') {
// clear the text from the box when clicked on
oText.value = '';
}
}
}
</script>
<cms:CMSTextBox
ID="txtWord" runat="server" onblur="setPlaceholdertext();" onclick="clearPlaceholdertext();" />