User Name Disappears

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>
LVL 14
RickEpnetAsked:
Who is Participating?
 
Kim WalkerWeb Programmer/TechnicianCommented:
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
 
GaryCommented:
Whats the code for the text box and what fires the event?
0
 
RickEpnetAuthor Commented:
<input name="j_username" type="text" id="j_username" onfocus="changeauname()" onBlur="restoreuname()" value="#usern#" size="20" />
0
 
GaryCommented:
Works fine, is that your complete js?  There must be something else interfering with it, do you have a live url to test?
0
 
RickEpnetAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.