Form text field - delete initial value on enter

A

ancient_hilly

Hello.. I would like the default text appearing in a form field to be
higlighted and deleted automatically after users have tabbed into the field
and started typing.
Is this possible, please? Currently users have to select and remove the
'helpful' text manually.
Thank you.
[Using FrontPage 2002]
 
T

Thomas A. Rowe

Yes, this is possible, but requires JavaScript.

Do a search in IE address for:

? JavaScript Remove Initial Form Field Values.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
J

Jon Spivey

Hi,
Like this
<input type="text" value="enter your name" onfocus="this.select();"
onkeydown="if(this.value==this.defaultValue)this.value='';">
 
M

Murray

<input name="firstname" type="text" id="firstname"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue" value="Enter Your
First Name">

I like this one because it uses onFocus and onBlur. The default entry gets
erased and replaced if nothing is changed.

--
Murray
============

Jon Spivey said:
Hi,
Like this
<input type="text" value="enter your name" onfocus="this.select();"
onkeydown="if(this.value==this.defaultValue)this.value='';">

--
Cheers,
Jon
Microsoft MVP

ancient_hilly said:
Hello.. I would like the default text appearing in a form field to be
higlighted and deleted automatically after users have tabbed into the
field
and started typing.
Is this possible, please? Currently users have to select and remove the
'helpful' text manually.
Thank you.
[Using FrontPage 2002]
 
J

Jon Spivey

This comes down to personal choice. The way I like a form to work is
1/ The form field says "your name"
2/ You click in the field and "your name" is highlighted
3/ As soon as you press a key "your name" is deleted

Your onblur is a nice touch. Hopefully the guy has an answer he can use.

--
Cheers,
Jon
Microsoft MVP

Murray said:
<input name="firstname" type="text" id="firstname"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue" value="Enter Your
First Name">

I like this one because it uses onFocus and onBlur. The default entry
gets erased and replaced if nothing is changed.

--
Murray
============

Jon Spivey said:
Hi,
Like this
<input type="text" value="enter your name" onfocus="this.select();"
onkeydown="if(this.value==this.defaultValue)this.value='';">

--
Cheers,
Jon
Microsoft MVP

ancient_hilly said:
Hello.. I would like the default text appearing in a form field to be
higlighted and deleted automatically after users have tabbed into the
field
and started typing.
Is this possible, please? Currently users have to select and remove the
'helpful' text manually.
Thank you.
[Using FrontPage 2002]
 
M

Murray

Yes - that's a nice variant...

They could easily be combined....

--
Murray
============

Jon Spivey said:
This comes down to personal choice. The way I like a form to work is
1/ The form field says "your name"
2/ You click in the field and "your name" is highlighted
3/ As soon as you press a key "your name" is deleted

Your onblur is a nice touch. Hopefully the guy has an answer he can use.

--
Cheers,
Jon
Microsoft MVP

Murray said:
<input name="firstname" type="text" id="firstname"
onFocus="if(this.value==this.defaultValue)this.value=''"
onBlur="if(this.value=='')this.value=this.defaultValue" value="Enter Your
First Name">

I like this one because it uses onFocus and onBlur. The default entry
gets erased and replaced if nothing is changed.

--
Murray
============

Jon Spivey said:
Hi,
Like this
<input type="text" value="enter your name" onfocus="this.select();"
onkeydown="if(this.value==this.defaultValue)this.value='';">

--
Cheers,
Jon
Microsoft MVP

message Hello.. I would like the default text appearing in a form field to be
higlighted and deleted automatically after users have tabbed into the
field
and started typing.
Is this possible, please? Currently users have to select and remove
the
'helpful' text manually.
Thank you.
[Using FrontPage 2002]
 
A

ancient_hilly

Thank you to everyone for your input. I will try out all options. Many
thanks and a Happy Christmas to you all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top