Do you notice the nifty email subscription box on the sidebar. If you are a feed reader, you might want to click-through to check out. In this simple tutorial, I’ll teach you how to create this simple form using javascript.
1) First, here is the basic HTML code for an input box and a subscribe button :
2) Then, we have to add the javascript bit to make the text field blank when a user clicks inside it. For this, we make use of the onClick parameter
The if statement is pretty much self explanatory. On clicking, if the value inside the text field is “Enter Email Address…”, we should change its value to blank.
if(this.value == 'Enter Email Address..')
{
this.value = '';
}
3) Now, that form is almost complete. We just need to add one more thing. When the user doesn’t enter any value and clicks outside the text field, we should bring back the “Enter Email Address…”. For this, we make use of the onBlur parameter.
This is also the same as the other statement. On blur (clicking somewhere outside), ifthe value of the text field is blank, we have to change it to “Enter Email Address…”
if(this.value == '')
{
this.value = 'Enter Email Address..';
}
Thats it. Now, you have a cool form for email subscriptions (of course, this can be used for any other form).

Thanks that is really helpful. Do you have anything for validating email addresses using JavaScript?