?
Solved

read only text area or alternative

Posted on 2011-03-09
11
Medium Priority
?
271 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:Shawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 30

Expert Comment

by:LZ1
ID: 35086933
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.  
0
 
LVL 1

Author Comment

by:Shawn
ID: 35087082
sounds good. do you have a quick example. never done that before and I'm not too hot with borders in css.
0
 
LVL 30

Expert Comment

by:LZ1
ID: 35087131
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

0
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
LVL 1

Author Comment

by:Shawn
ID: 35087252
I get the box and text but the text goes out of the box rather then having the side bar appear.
0
 
LVL 30

Expert Comment

by:LZ1
ID: 35087263
Add overflow:scroll;
0
 
LVL 1

Author Comment

by:Shawn
ID: 35087293
ok, I have the box looking nice now but I still have the same backspace behavior.
0
 
LVL 30

Expert Comment

by:LZ1
ID: 35087328
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.  
0
 
LVL 1

Author Comment

by:Shawn
ID: 35087360
i suppose I could use js. At least it could change that function. any ideas?
0
 
LVL 30

Accepted Solution

by:
LZ1 earned 2000 total points
ID: 35087403
I got this code from here: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_20276433.html 


Try this:
<script>
function checkShortcut()
{
                  if(event.keyCode==8 || event.keyCode==13)
         {
               return false;
         }
}
 </script>
<body onkeydown="return checkShortcut()">

Open in new window

0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 35087432
it all works perfect now. thank you
0
 
LVL 30

Expert Comment

by:LZ1
ID: 35087441
Glad I could help!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question