Solved

read only text area or alternative

Posted on 2011-03-09
11
264 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
  • 6
  • 5
11 Comments
 
LVL 30

Expert Comment

by:LZ1
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:Shawn
Comment Utility
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
Comment Utility
Add overflow:scroll;
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

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

Expert Comment

by:LZ1
Comment Utility
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
Comment Utility
i suppose I could use js. At least it could change that function. any ideas?
0
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
Comment Utility
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
Comment Utility
it all works perfect now. thank you
0
 
LVL 30

Expert Comment

by:LZ1
Comment Utility
Glad I could help!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now