473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

removing the default value for an input box

Hi Folk

For input boxes in forms, some forms have default values e.g. "enter
phone number here". When a user wants to enter their details, they
first have to remove the default entry - which can be a bit annoying
at times. I have written a very simple little script (obviously not
the first one) that removes the default entry. You can find it here:

http://www.sunnysideup.co.nz/j/form/

Cheers

Nicolaas

Jul 11 '07 #1
2 3530
On Jul 12, 7:53 am, windandwaves <nfranc...@gmail.comwrote:
Hi Folk

For input boxes in forms, some forms have default values e.g. "enter
phone number here". When a user wants to enter their details, they
first have to remove the default entry - which can be a bit annoying
at times. I have written a very simple little script (obviously not
the first one) that removes the default entry. You can find it here:

http://www.sunnysideup.co.nz/j/form/
Some suggestions...

You should only apply the function to text inputs, not all input
elements.

When the control is blurred and nothing is entered, you return it to
the default value. However, when the control next receives focus, the
function doesn't fire. Onfocus you might like to test something like:

if (input.value == input.defaultValue) input.value = '';

You might be better off to apply the handler based on the control's
class, that way you can apply it to textarea elements too.
--
Rob

Jul 11 '07 #2
On Jul 12, 11:37 am, RobG <r...@iinet.net.auwrote:
On Jul 12, 7:53 am, windandwaves <nfranc...@gmail.comwrote:
Hi Folk
For input boxes in forms, some forms have default values e.g. "enter
phone number here". When a user wants to enter their details, they
first have to remove the default entry - which can be a bit annoying
at times. I have written a very simple little script (obviously not
the first one) that removes the default entry. You can find it here:
http://www.sunnysideup.co.nz/j/form/

Some suggestions...

You should only apply the function to text inputs, not all input
elements.

When the control is blurred and nothing is entered, you return it to
the default value. However, when the control next receives focus, the
function doesn't fire. Onfocus you might like to test something like:

if (input.value == input.defaultValue) input.value = '';

You might be better off to apply the handler based on the control's
class, that way you can apply it to textarea elements too.

--
Rob
Thanks Rob.

MUCH APPRECIATE your comments - as always! Thank you. I will use
those ideas.

Jul 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Peter O'Reilly | last post by:
I have an HTML form with a textarea input box. When the user conducts a post request (e.g. clicks the submit button), an HTML preview page is presented to them with the information they have...
7
by: Utter Newbie | last post by:
Just wondeing if there is a way to keep from having a certain parameter sent when posting a form to another page (method=get)... So as an example a page will post something like this from a form...
21
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
9
by: Rob Meade | last post by:
Hi all, Ok - so I've got the array thing going on, and the session thing going on, and up until now its all been ok. I've got my view basket page which is displaying 3 rows (as an example) - I...
12
by: Doogie | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself,...
12
by: joestevens232 | last post by:
Hello Im having problems figuring out how to remove the duplicate entries in an array...Write a program that accepts a sequence of integers (some of which may repeat) as input into an array. Write...
16
by: Lorum | last post by:
Hi, Is it possible for me to, when I choose an option eg. 'Iveco', to let the text/input field disappear? So basically, if you choose a car in the first dropdownmenu, the text/input field has to...
20
omerbutt
by: omerbutt | last post by:
hi there i am making an application in which i have to populate columns that consist of some textfields and some input boxes the problem is at the mozilla's end, it creates a new node and appends the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.