Forum Moderators: open
i have created a form which, on this site i want the desciption of each feild within the box,
ie: Name
Email.....and so on.
Some may think why not use <label for=""> tags or place the box descriptions outside, and although I have done this most times before i want a different look this time.
What i want to know though is how to make the text within the box disappear when the user clicks on to fill their details in. At the moment im having to delete say...Name, then fil in my name.
thanks for any help.
geoff
What is a tag? Perhaps you were speaking about elements? Correct syntax, correct references, correct questions, get correct answers. ;)
Anyway ... are you asking to make the label's text disappear or change when the user types something in to the input field?
- John
XHTML Minimal code...
<form action="" method="post">
<fieldset>
<label for="example">your field description</label><input id="example" name="example" type="text />
</fieldset>
</form>
<html><head>
<script>
function clear(field)
{
if (field.defaultValue == field.value)
field.value = ""
}
</script>
</head><body>
<form>
<input type="text" value="Search" onfocus="clear(this)">
</form></body>
</html>
Hope this helps.
Milan
tried the code but to no avail,
<head>
<script>
function clear(field)
{
if (field.defaultValue == field.value)
field.value = ""
}
</script>
</head>
<body>
<form action=""....blar blar>
<input name="name" type="text" id="name" value="name" onFocus="clear(this)">
<input name="telephone" type="text" value="telephone" onFocus="clear(this)">
<input name="email" type="text" value="email" onFocus="clear(this)">
</form>
</body>
have I done something wrong, any thoughts?
cheers for help geoff
<head><script>
function clearValue(field)
{
if (field.defaultValue == field.value)
field.value = "";
}
</script></head>
<body>
<form action="">
<input name="name" type="text" id="name" value="name" onFocus="clearValue(this)">
<input name="telephone" type="text" value="telephone" onFocus="clearValue(this)">
<input name="email" type="text" value="email" onFocus="clearValue(this)">
</form></body>
Milan