PDA

View Full Version : Control textbox text on events



ismailc
09-17-2009, 06:29 AM
Good day, Functions neeeded.

I have a search textbox where I would like to display the "Search Keywords" in text of textbox when blank but when mousemove clear text.

1. When textbox is blank then I would like to display text value "Search Key"
2. Onmouseover & Focus: when text value "Search Key" then blank else valu
3. OnMouseLeave / loosefocus: when text value blank then "Search Key" else value
4. I would also like to change the font.

Please Assist

ismailc
09-17-2009, 02:22 PM
Hi, I found the below worked for me - not good coding.

<script type="text/javascript" language="javascript">
var EMPTY = "";

function In()
{
var handle = document.getElementById("<%=TextBox1.ClientID%>").value;
var initialText = "Process";

if (handle == initialText)
{
document.getElementById("<%=TextBox1.ClientID%>").value = EMPTY;
document.getElementById('<%=TextBox1.ClientID%>').style.fontStyle = "normal";
}
}

function Out()
{
var handle = document.getElementById("<%=TextBox1.ClientID%>").value;
var initialText = "Process";

if (handle == EMPTY)
{
document.getElementById("<%=TextBox1.ClientID%>").value = initialText;
document.getElementById('<%=TextBox1.ClientID%>').style.fontStyle = "italic";
}
}

</script>