...

View Full Version : Removing default value from text box on click...



dysfunctionGazz
12-15-2005, 03:10 PM
Hey all

I think this should be simple as ive seen it done many times.

I have a text box for my mailing list, which displays "enter your email" in the box as default. But I want this text to disappear, leaving the box blank, when the user clicks inside it.

This may be a javascript trick I suspect but either way if someone could show me how to clear the box when the user clicks into it, that would be great.

Thanks

mark87
12-15-2005, 04:48 PM
You're right in thinking you'll need Javascript.

http://www.codeave.com/javascript/code.asp?u_log=7008

circusbred
12-15-2005, 05:20 PM
Here is an example:

<script type="text/javascript">
function valueFocus(e,d) {
if(e.value == d) e.value = '';
}
function valueBlur(e,d) {
if(e.value == '') e.value = d;
}
</script>

<input name="email" id="email" onfocus="valueFocus(this,'Enter Your Email');" onblur="valueBlur(this,'Enter Your Email');" value="Enter Your Email" />

This way, if someone selects the input, enters nothing, then selects something else, 'Enter Your E-mail' will come back.

dysfunctionGazz
12-15-2005, 11:52 PM
Thanks Circusbred, that works perfectly!

Thanks for the link Mark87, I used the example given but thanks for your help also :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum