input value question

Discussion in 'HTML' started by hhservices, Oct 29, 2003.

  1. hhservices

    hhservices Guest

    My question pertains to a contact form where someone would type their
    phone number. Example:
    <input type="text" name="Phone" size="30" value="(include area code)">

    The type of input that I am searching for is when the page is viewed
    then words (include area code) would be visible in the form and then
    when someone clicks the input box, then the words include area code
    would disappear and then they could type their phone number with the
    area code.

    Thanks in advance,
    Victor
     
    hhservices, Oct 29, 2003
    #1
    1. Advertising

  2. (hhservices) wrote:

    > My question pertains to a contact form where someone would type their
    > phone number. Example:
    > <input type="text" name="Phone" size="30" value="(include area code)">


    That's not a good approach, since the value attribute, if present, should
    specify a useful initial (default) value for the field.

    > The type of input that I am searching for is when the page is viewed
    > then words (include area code) would be visible in the form and then
    > when someone clicks the input box, then the words include area code
    > would disappear and then they could type their phone number with the
    > area code.


    You could do that, with the usual caveats, using a simple piece of
    JavaScript. But it is better to avoid creating the problem in the first
    place. Use something like

    <div>Please specify your full phone number, including area code.</div>
    <div><label for="phone">Phone:</label>
    <input type="text" id="phone" name="Phone" size="30"></div>

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Oct 30, 2003
    #2
    1. Advertising

  3. (hhservices) wrote in message news:<>...
    > My question pertains to a contact form where someone would type their
    > phone number. Example:
    > <input type="text" name="Phone" size="30" value="(include area code)">
    >
    > The type of input that I am searching for is when the page is viewed
    > then words (include area code) would be visible in the form and then
    > when someone clicks the input box, then the words include area code
    > would disappear and then they could type their phone number with the
    > area code.
    >
    > Thanks in advance,
    > Victor


    You could probably do something with Javascript, but IMHO, the best
    thing to do is to place the instruction under the input box, just like
    on a paper form.

    --
    Adrienne Boswell
    Please respond to the group so others can share
    http://www.arbpen.com
     
    Adrienne Boswell, Oct 30, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Melissa
    Replies:
    2
    Views:
    612
    Gaurav Vaish \(a.k.a. MasterGaurav\)
    Dec 26, 2008
  2. chirs
    Replies:
    3
    Views:
    141
    Sergey I.Grachyov
    Oct 18, 2003
  3. Susan Cranford
    Replies:
    2
    Views:
    403
  4. Dwizz
    Replies:
    10
    Views:
    393
  5. Christa Lee

    Form Input Value to change a later value

    Christa Lee, Oct 1, 2005, in forum: Javascript
    Replies:
    2
    Views:
    97
Loading...

Share This Page