PDA

View Full Version : disable textfield entry using JS?


homerUK
12-22-2002, 11:03 AM
hi everyone (again!!)

is it possible to make a function in JS which will disable a textfield?

I know you can add "readonly" to the field... but can this be done via the javascript on an event?

thanks!

brothercake
12-22-2002, 01:15 PM
you could try

<form><textarea onkeypress="return false"></textarea></form>

Mr J
12-22-2002, 03:27 PM
Will this do?




<SCRIPT>
function enable(){
if (document.test1.test1.disabled==true)
document.test1.test1.disabled=false
else
document.test1.test1.disabled=true
}
</SCRIPT>

<FORM name=test1>
<P><INPUT type=text value="Hello World" name="test1" disabled=true> <A href="javascript:enable()">Click here</A>
</FORM>