On 29 Apr 2005 08:23:27 -0700, "RobB" <fe******@hotmail.com> wrote:
James Bond 007 wrote: 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
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?
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.myform.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="return 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.