We help IT Professionals succeed at work.

How do I code an ASP form so light-font type can appear in a text box?

kfranck
kfranck asked
on
I have created an ASP form that sends data to access database. In one of the text boxes, I would like to include in the value a few words in light type. I also like the words to disappear when the user enters data into the box. How can this be done and can I adjust the font size of the type?

Here is the code:

<input
                   style="border:2px solid #C7D5F1; BACKGROUND-COLOR: #FFFFFF; font-weight:700"
          name="Staff" size="25" value="Enter STAFF if more than 2"></font><b><font size="2" color="#660000">
                                                            </font></b><font color="#660000">
Comment
Watch Question

Wayne BarronAuthor, Web Developer
Top Expert 2009

Commented:
Here you go

Carrzkiss

<input onBlur="javascript:if (this.value == '') this.value = 'Your Name';" onFocus="javascript:if (this.value == 'Your Name') this.value='';" value="Your Name" />

Open in new window

Author

Commented:
Carrzkiss:

Thank you. Do I put this javascript at the top of the page?
Author, Web Developer
Top Expert 2009
Commented:
Nope, you put it in just like I have it in the example.
It is all within the line of code.

Just add it into your existing code like this.
Carrzkiss

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.input{
	border:2px solid #C7D5F1;
	background-color:#FFF;
	font-weight:700;
}
</style>
</head>

<body>
<input class="input" name="Staff" size="25" onBlur="javascript:if (this.value == '') this.value = 'Enter STAFF if more than 2';" onFocus="javascript:if (this.value == 'Enter STAFF if more than 2') this.value='';" value="Enter STAFF if more than 2" />
</body>
</html>

Open in new window

Author

Commented:
Great! You're terrific. Thanks.