Could use some help with a form I am building for my WordPress theme. Trying to get value that appears when the form loads, hides when the users clicks in the field and returns if the user clicks outside the field without adding any content. This was pretty easy by using value, onblur and onfocus. Here is where things get tricky...
When hitting send and generating an error, the form will reload for the user with an error message. I want the form to retain the information they typed into the form. Solved that too. However, now the basic value isn't there and the form field is empty until clicked in and clicked out of. Suggestions?
Here's an example:
<input type="text" name="email" id="email" value="<?php if (isset($_POST['email'])) echo $_POST['email'] ;?>" onfocus="if(this.value=='Your Email is')this.value='';" onblur="if(this.value=='')this.value='Your Email is';" alt="Your Email" />
The trouble I am having is setting up an if/else statement for the value that does the following:
* includes "Your email is" in the field when the form loads
* auto blanks the field when the user clicks in it
* reloads "Your email is" if the user clicks outside the field without entering content
* retains the information they typed in the field if they reload the page or if they submit and the form found an error
Thanks for reading this over.