Click to See Complete Forum and Search --> : javascript form field value
planeboy747
10-18-2005, 10:33 PM
On my website, gayeventsguide.com, I have a place to signup for my newsletter at the top right.
In the form field it says "Enter Email"
How do I create a javascript that once the focus is placed inside the box it will remove the "Enter Email" statement?
Thanks
Jacob
<input type="text" onfocus="this.value='';this.onfocus=null" value="Enter Email">
planeboy747
10-18-2005, 11:16 PM
perfecto! Thanks...here's next question, if focus is taken off the field, then it doesnt put "Enter Email" back in the box, how do I do that?
now you need functions
<script type="text/javascript">
function input_onfocus(el){
el.value='';
el.onfocus=null
}
function input_onblur(el){
el.value='Enter Email';
el.onfocus=function(){
input_onfocus(this)
}
}
</script>
</head>
<body>
<input type="text" onfocus="input_onfocus(this)" onblur="input_onblur(this)" value="Enter Email">