Q: Form widget default value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Bond 007

    #1

    Q: Form widget default value

    Given the following example, I want "Jane Doe" to appear
    when the user first views the form, and when he leaves it blank:

    // ----------------
    <FORM .... >
    Name:
    <INPUT TYPE="text" NAME="user_name " VALUE="Jane Doe"
    SIZE="25" MAXLENGTH="30" REQUIRED="YES">
    // ----------------

    I presume it needs an event handler
    using "onselect" and/or "onblur", or something like that,
    but I have no idea what the specifics are,
    and I'm trying to avoid creating a function for it!

    I figure there *has* to be a simple way of doing the above!

    I scoured the net and couldn't find anything useful,
    but if you know of a helpful URL, then, by all means,
    please tell me what it is!

    Any help would be appreciated!

    Thanks!



    -----
    Bond . . . James Bond


    Do not reply via e-mail.
    The address is phony to prevent spam, etc.
    Thank you for understanding.
  • RobB

    #2
    Re: Q: Form widget default value

    James Bond 007 wrote:[color=blue]
    > Given the following example, I want "Jane Doe" to appear
    > when the user first views the form, and when he leaves it blank:
    >
    > // ----------------
    > <FORM .... >
    > Name:
    > <INPUT TYPE="text" NAME="user_name " VALUE="Jane Doe"
    > SIZE="25" MAXLENGTH="30" REQUIRED="YES">
    > // ----------------
    >
    > I presume it needs an event handler
    > using "onselect" and/or "onblur", or something like that,
    > but I have no idea what the specifics are,
    > and I'm trying to avoid creating a function for it!
    >
    > I figure there *has* to be a simple way of doing the above!
    >
    > I scoured the net and couldn't find anything useful,
    > but if you know of a helpful URL, then, by all means,
    > please tell me what it is!
    >
    > Any help would be appreciated!
    >
    > Thanks!
    >
    >
    >
    > -----
    > Bond . . . James Bond
    >
    >
    > Do not reply via e-mail.
    > The address is phony to prevent spam, etc.
    > Thank you for understanding.[/color]

    007 -

    Well, one way or another, you'll be using a function for
    this...probably meant a separately declared (global) function.

    Could you elaborate on this?
    [color=blue]
    > I want "Jane Doe" to appear when the user first
    > views the form, and when he leaves it blank:[/color]

    Comment

    • James Bond 007

      #3
      Re: Q: Form widget default value

      On 29 Apr 2005 08:23:27 -0700, "RobB" <ferndoc9@hotma il.com> wrote:
      [color=blue]
      >James Bond 007 wrote:[color=green]
      >> Given the following example, I want "Jane Doe" to appear
      >> when the user first views the form, and when he leaves it blank:
      >>
      >> // ----------------
      >> <FORM .... >
      >> Name:
      >> <INPUT TYPE="text" NAME="user_name " VALUE="Jane Doe"
      >> SIZE="25" MAXLENGTH="30" REQUIRED="YES">
      >> // ----------------
      >>
      >> I presume it needs an event handler
      >> using "onselect" and/or "onblur", or something like that,
      >> but I have no idea what the specifics are,
      >> and I'm trying to avoid creating a function for it!
      >>
      >> I figure there *has* to be a simple way of doing the above!
      >>
      >> I scoured the net and couldn't find anything useful,
      >> but if you know of a helpful URL, then, by all means,
      >> please tell me what it is!
      >>
      >> Any help would be appreciated!
      >>
      >> Thanks!
      >>
      >>
      >>
      >> -----
      >> Bond . . . James Bond[/color][/color]
      [color=blue]
      >007 -
      >
      >Well, one way or another, you'll be using a function for
      >this...probabl y meant a separately declared (global) function.
      >
      >Could you elaborate on this?[/color]

      I came up with the following,
      but it doesn't re-fill the default value
      if the user leaves the box blank
      (the Reset function does that,
      but I don't want the user to have to do that):

      // (purposely omitted stuff)

      // if field is blank, then show alert
      function formCheck() {
      if (document.myfor m.name.value==" ") }
      alert("Please fill-in ALL the boxes!");
      return false;
      }

      // (purposely omitted stuff)

      // call formCheck (above) when user hits "Submit" button
      <FORM NAME="myform" METHOD="POST" ACTION="(cgi)"
      onSubmit="retur n formCheck()">

      // (purposely omitted stuff)

      <INPUT NAME="name" TYPE="text" MAXLENGTH="35" SIZE="35"
      required="YES" VALUE="Jane Doe">

      I'm thinking that just after the "VALUE" part, in the above line,
      there should be something like this:

      onExitFromField ="(if value is blank then 'alert' and reset to
      "Jane Doe")"

      Now, if someone could tell me what the above line
      should *really* look like . . . !!!

      Thanks!



      -----
      Bond . . . James Bond


      Do not reply via e-mail.
      The address is phony to prevent spam, etc.
      Thank you for understanding.

      Comment

      • Mick White

        #4
        Re: Q: Form widget default value

        James Bond 007 wrote:
        [snip][color=blue]
        >
        > <INPUT NAME="name" TYPE="text" MAXLENGTH="35" SIZE="35"
        > required="YES" VALUE="Jane Doe">
        >
        > I'm thinking that just after the "VALUE" part, in the above line,
        > there should be something like this:
        >
        > onExitFromField ="(if value is blank then 'alert' and reset to
        > "Jane Doe")"
        >[/color]


        Mick

        Comment

        Working...