[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

User Name Disappears

Posted on 2012-08-14
5
Medium Priority
?
472 Views
Last Modified: 2012-08-14
I have an HTML form that has a login. I have created a user name field (j_username) that when someone clicks the word username Disappears and they can type in. This works great in Chrome but not in IE can anyone help me with this?

<script language="JavaScript" type="text/javascript">
function changeauname() {
      document.getElementById('j_username');
      j_username.value = "";
       }
function restoreuname() {
    if(document.getElementById('j_username').value=='')
      {
      document.getElementById('j_username');
      j_username.value = 'username';
          }
      }      
</script>
0
Comment
Question by:RickEpnet
  • 2
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 38292880
Whats the code for the text box and what fires the event?
0
 
LVL 14

Author Comment

by:RickEpnet
ID: 38293058
<input name="j_username" type="text" id="j_username" onfocus="changeauname()" onBlur="restoreuname()" value="#usern#" size="20" />
0
 
LVL 58

Expert Comment

by:Gary
ID: 38293081
Works fine, is that your complete js?  There must be something else interfering with it, do you have a live url to test?
0
 
LVL 14

Author Comment

by:RickEpnet
ID: 38293227
www.touchpointatm.com the problem is you will not be able to login to test it but you can see all the js on the page.
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 2000 total points
ID: 38293508
You haven't defined the variable j_username. Try:

<script language="JavaScript" type="text/javascript">
function changeauname() {
      document.getElementById('j_username').value = "";
       }
function restoreuname() {
    if(document.getElementById('j_username').value=='')
      {
      document.getElementById('j_username').value = 'username';
          }
      }      
</script>

Open in new window

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question