Forum Moderators: open
I have a working javascript function which clears the default value of an inputfield onFocus.
Now I built a php script around the input element:
I do not get any error, but onFocus/clearme does not work anymore :-(
<input type="text" name="name" value="name" onFocus="clearme(fe,'name')" size="20" tabindex=1>
should not be very difficult...
Thanks for your help!
Paul
>>>> but maybe you have also an idea because of my other posting:
[webmasterworld.com...]
this is my javascript block in the HTML <HEAD>
...
<script language="JavaScript">
function clearme(fe,txt){
// check to see that the form element is default
if (fe.value == txt){
// clear the default text
fe.value = "";
}
return;
}
</script>
</head>
and the call is
I think I was too busy with the syntax...
The advantage of "my" method (i copied it from a book) would be, that it only clears the field, if the default value is in the field...
if the user detects an mistake in his input he may return, and has not enter the whole input.
I use my clearme function also in a textarea...
or, more generically:
<input onfocus="if(this.value==this.defaultValue)this.value=''" type="text" value="some text" />
This approach should also work with a textarea, as I believe it also supports defaultValue.