Forum Moderators: open

Message Too Old, No Replies

onFocus problem

         

kevinj

6:34 pm on Nov 6, 2003 (gmt 0)

10+ Year Member



I have set up a textbox that includes the following JS.

<input type=text name=client_login size=12 maxlength=12 value="Login Failed" onFocus=document.login.client_login.value="" onChange=document.login.client_login.focus()>

This works perfect on a PC in IE. The problem occurs on the Mac in IE 5. When I click in the text box and it clears the value, then enter a value and hit the submit button, no value gets passed in the form to the next page so my login won't work on Mac. I've narrowed it down to the onFocus code. Anyone aware of this problem and a solution that will work on both Mac and PC?

Thanks much,
Kevin

korkus2000

6:36 pm on Nov 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried this?

onFocus="document.login.client_login.value=''"

AWildman

6:42 pm on Nov 6, 2003 (gmt 0)

10+ Year Member



Out of vulgar curiosity, why are you doing this: onFocus=document.login.client_login.value=""? If the input element is just getting focus, it shouldn't have a value. And if it does cause the user interacted with it previously, won't they be annoyed that it disappears the moment they go back to it? Also, I think you need quotes around "document.login.client_login.value=''". Have you tried running the code with the onfocus removed?

kevinj

6:50 pm on Nov 6, 2003 (gmt 0)

10+ Year Member



I have removed the onFocus code and then it works fine. The reason I was using it was my client would like the words "Client Login" in the textbox initially and when the user clicks in the box, they want the "Client Login" to disappear.

I will try adding the quotes.

kevinj

8:26 pm on Nov 6, 2003 (gmt 0)

10+ Year Member



I got it to work by removing the
onChange=document.login.client_login.focus()>

and changing the onFocus to onFocus="value=''"

Thanks.

dcrombie

12:52 pm on Nov 7, 2003 (gmt 0)



onFocus="if (this.value == this.defaultValue) this.value = '';"
onBlur="if (this.value == '') this.value=this.defaultValue;"

;)