Link to home
Start Free TrialLog in
Avatar of Shawn
ShawnFlag for Canada

asked on

read only text area or alternative

I have a site where there are conditions in a text area. I have set the text area to read only but noticed when you press the backspace it then takes you to the previous page.

Is there a way to prevent this (non js if possible) or maybe an alternative to textarea? kinda like the box I'm typing in right now but read only.
Avatar of LZ1
LZ1
Flag of United States of America image

You could just put the content in a div, give it a width and height and then add overflow: visible which will allow it to scroll.  
Avatar of Shawn

ASKER

sounds good. do you have a quick example. never done that before and I'm not too hot with borders in css.
Something like this would work:


CSS

	#textArea {
		width:500px; /*Change to suit your needs */
		height:250px;/*Change to suit your needs */
		clear:both;
		border:1px inset #333;
		}

Open in new window

HTML: 

<div id="textArea">
Your content here 
</div>

Open in new window

Avatar of Shawn

ASKER

I get the box and text but the text goes out of the box rather then having the side bar appear.
Add overflow:scroll;
Avatar of Shawn

ASKER

ok, I have the box looking nice now but I still have the same backspace behavior.
Unfortunately the only way to completely disable the backspace key would be Javascript.  It's a default function of the browser itself, as far as I understand it.  
Avatar of Shawn

ASKER

i suppose I could use js. At least it could change that function. any ideas?
ASKER CERTIFIED SOLUTION
Avatar of LZ1
LZ1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shawn

ASKER

it all works perfect now. thank you
Glad I could help!