Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 951
  • Last Modified:

Grey out textfield

How do you grey out a textfield? Make it read-only
0
funksoul
Asked:
funksoul
1 Solution
 
daveamourCommented:
<Input Type="Text" Name="Firstname" Value="Smith" Readonly>

Dave
0
 
xabiCommented:
This will be a better solution:

<input type="text" name="foo" value ="foo" onfocus="this.blur()" Readonly>

cause readonly tag is only IE compatible.

xabi
0
 
funksoulAuthor Commented:
I need to know how to do this by using Javascript...

document.forms[0].elements[0].disabled=true

but this only works for IE...does Netscape support grey-out readonly.
0
 
Michel PlungjanIT ExpertCommented:
Xabis solution is correct, however it always disables the field.

Here is ow it should be

<input type="text" name="foo" value ="foo" onfocus="if (this.disabled) this.blur()">

it will NOT be greyed out in Netscape but it WILL be disabled using
document.forms[0].elements[0].disabled=true;

Michel
0
 
funksoulAuthor Commented:
I wish I could give you both points...but thanks fo r the help...only wish Netscape has the grey out option too.
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.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now