Created
March 21, 2012 10:17
-
-
Save mozz100/2145983 to your computer and use it in GitHub Desktop.
Simulate 'placeholder' with Javascript
This file contains 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
// clear the email address field when the user clicks into it | |
function clickClear(e) { | |
if (e.value == 'Your email address') { // text must match the default value attribute on the <input> tag | |
e.value = ''; | |
} | |
} |
This file contains 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
<!-- here's the html snippet. The important bits are the value and onfocus attributes --> | |
<input name="Email" id="Email" | |
type="text" value="Your email address" | |
maxlength="255" tabindex="2" | |
onfocus="clickClear(this);" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment