Created
June 26, 2012 17:41
-
-
Save computercarguy/2997362 to your computer and use it in GitHub Desktop.
JavaScript to give you the ability to put default text in a text field, then remove it when a user clicks the field, and put that text back in if they leave the field empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Focus(TextboxName,TheValue){ | |
| if (document.getElementById(TextboxName).value == TheValue){ | |
| document.getElementById(TextboxName).value = ""; | |
| } } | |
| function Blur(TextboxName,TheValue){ | |
| if (document.getElementById(TextboxName).value == ""){ | |
| document.getElementById(TextboxName).value = TheValue; | |
| } } | |
| // usage in X/D/HTML | |
| <input type="text" value="First Name:" name="First" id="First" onfocus="Focus('First','First Name:')" onblur="Blur('First','First Name:')" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment