Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form elements

Status
Not open for further replies.

jlynch1

Technical User
Dec 20, 2001
100
IE
is there any way of preventing form elements like text boxs from being edited by using javascript.
 
No problem. You don't need to use javascript.

Just use the attribute
Code:
readonly
within your textfield or textbox.
E.g.
Code:
<input name=&quot;test&quot; type=&quot;text&quot; value=&quot;not editable&quot; readonly>
 
hi jlynch1,

There are 2 HTML ways:
1) <input type=&quot;text&quot; disabled>
makes the text grey if you have a value in it
<input type=&quot;text&quot; disabled value=&quot;grey text&quot;>

2) <input type=&quot;text&quot; readonly>

The javascript way is:
<HTML>
<HEAD>
</HEAD>
<BODY onload=&quot;Disab()&quot;>

<script language=&quot;javascript&quot;>
function Disab()
{
document.webform2.t1.disabled = true
}
</script>

<form name=&quot;webform2&quot;><br>
<input type=&quot;text&quot;name=&quot;t1&quot;><br>
</form>
</BODY>
</HTML>

You can reset the disabling with document.webform2.t1.disabled = false

Hope this helps,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top