the Forum

Form placeholders - Using Javascript

Posted on June 29, 2012 by Michael Rosario
Total Posts: 33  |  Join date: 03-12-11

Since the placeholder parameter is still not 100% supported in all browsers, here is an alternative:
<input type="text" name="Email" onfocus="if (this.value == 'Your email address...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Your email address...';}" value="Your email address..." /> 

Tags: There are no tags for this entry.

1 answer, add yours below

Posted on on July 17, 2012 at 9:51am
by Michael Rosario

Here is the version for PASSWORD placeholder:

<input name="password" type="text" value="password" 
onfocus="
          this.type='password'; 
          this.style.color='#000000'; 
                  if(this.value == 'password') {
                               this.value = '';
                   } else { 
                               this.style.color='#000000'; 
                   }" 
onblur="
          if (this.value == '') {
                    this.value = 'password'; 
                    this.style.color='#848484'; 
                    this.type='text';
                  } else { 
                    this.type='password'; 
                    this.style.color='#000000'; 
            }"

 
add your answers here
comments powered by Disqus