> > Sorry for the confusion, when you first posted I had thought the name
> > of your input element was "e-mail". Try the same solution this time
[quoted text clipped - 3 lines]
>
> Thanks but it's still not working...
The current action is still submitting the form. The onClick even
expects a boolean value to be returned. To see the expected result you
are looking for, do the following:
<input type="submit" value="Go!"
onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
return false;">
John - 28 Sep 2005 22:38 GMT
> The current action is still submitting the form. The onClick even
> expects a boolean value to be returned. To see the expected result you
[quoted text clipped - 3 lines]
> onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
> return false;">
Thanks, it makes sense, but it's still not working. I tried changing the
value from email to e-mail as that's the value in the previous statement is
but still nothing.
ASM - 28 Sep 2005 23:44 GMT
John a écrit :
>><input type="submit" value="Go!"
>>onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
[quoted text clipped - 3 lines]
> value from email to e-mail as that's the value in the previous statement is
> but still nothing.
<form action="foo.htm"
onsubmit="if(this.email.value=='e-mail'){
this.email.value='';
return false;
}
else
return true;">
<input type=text name="email" value="e-mail">
<input type=submit value=GO>
</form>

Signature
Stephane Moriaux et son [moins] vieux Mac
John - 30 Sep 2005 21:57 GMT
> <form action="foo.htm"
> onsubmit="if(this.email.value=='e-mail'){
[quoted text clipped - 6 lines]
> <input type=submit value=GO>
> </form>
Thanks! :-)
Evertjan. - 30 Sep 2005 23:19 GMT
ASM wrote on 29 sep 2005 in comp.lang.javascript:
> <form action="foo.htm"
> onsubmit="if(this.email.value=='e-mail'){
> this.email.value='';
> return false;
> }
> else
no need for the else here!
> return true;">
> <input type=text name="email" value="e-mail">
> <input type=submit value=GO>
> </form>
even shorter is:
onsubmit="
if(this.email.value!='e-mail')
return true;
this.email.value='';
return false;"

Signature
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Lee - 28 Sep 2005 22:43 GMT
web.dev said:
>> > Sorry for the confusion, when you first posted I had thought the name
>> > of your input element was "e-mail". Try the same solution this time
[quoted text clipped - 11 lines]
>onClick="if(this.form.elements['email'].value=='email'){this.form.elements['email'].value='';}
>return false;">
Better:
Never, ever, use the onclick handler of a submit button.
Use the onsubmit handler of the form tag, instead.
John - 28 Sep 2005 23:10 GMT
> Better:
>
> Never, ever, use the onclick handler of a submit button.
> Use the onsubmit handler of the form tag, instead.
Only problem with that is that the user never sees the text "e-mail"
disappear if it has to be submitted. Rather, I'd want them to see the text
disappear when they click on the submit button.This way, if the form is
submitted, then a blank address gets emailed instead of "email" being
submitted as an email address.
Lee - 28 Sep 2005 23:59 GMT
John said:
>> Better:
>>
[quoted text clipped - 6 lines]
>submitted, then a blank address gets emailed instead of "email" being
>submitted as an email address.
Well, if you're not actually submitting anything, don't freaking use
a submit button. Use a regular button.
John - 29 Sep 2005 01:10 GMT
> Well, if you're not actually submitting anything, don't freaking use
> a submit button. Use a regular button.
It *is* submitting something, an email address. But if the email address is
"email" I want it blank.
Lee - 30 Sep 2005 22:38 GMT
John said:
>> Well, if you're not actually submitting anything, don't freaking use
>> a submit button. Use a regular button.
>
>It *is* submitting something, an email address. But if the email address is
>"email" I want it blank.
If you're submitting, and you want something to happen first, and/or
you want the submission to be cancelled under certain circumstances,
then use the onsubmit handler of the form. Do NOT use the onclick
handler of the submit button.