473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Prevent users from entering data into a textbox.

I teach HS computers and one of my kids has a web site with a textbox of
info that the user can scroll down and read. The problem is that users can
also enter text into it. Is there a way, or a better control, method, to
prevent user from entering text?

Thanks,
Jim
Jul 21 '05 #1
7 6814
JimO <jo********************@earthlink.net> wrote:
I teach HS computers and one of my kids has a web site with a textbox of
info that the user can scroll down and read. The problem is that users can
also enter text into it. Is there a way, or a better control, method, to
prevent user from entering text?


Assuming that the "textbox" is a TEXTAREA element, its whole purpose is to
accept text from the user. There is no way to make it stop accepting text
from the user.

If you (or your student) gets rid of the TEXTAREA and marks up the text
normally (paragraphs, headings, lists, etc.), then the browser will provide
appropriate scrolling mechanisms automatically, if scrolling is needed.

If you put the marked-up text in a DIV element, then you can use CSS to
specify the size and scrolling behavior of the DIV element. But such things
often prevent the user from scrolling through the content normally (e.g.,
with the arrow keys, or with the Page Up or Page Down keys), so it's better
to let the browser handle scrolling on its own.
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"There is no right way to do the wrong thing."
Jul 21 '05 #2
On Tue, 22 Feb 2005, JimO wrote:
I teach HS computers and one of my kids has a web site with a
textbox of info that the user can scroll down and read.
If you're referring to a forms textarea, then that's precisely what it
was designed for.
The problem is that users can also enter text into it.
No, that's not the problem. The /problem/ is that it's being misused
for something that it wasn't intended for.
Is there a way, or a better control, method, to prevent user from
entering text?


Probably, What, actually, are you (or they) trying to achieve?
The crystal ball is cloudy, and there's no extra charge for telling
usenet - a bit more clearly - what the real-world problem is (in
preference to telling them what the failed solution was, and leaving
them to try and guess what the actual problem was, I mean)

Maybe <object...> or even (shudder) <iframe...> was what was intended?
But, if that was the answer (given the current browser support etc.),
there could have been something wrong with the question. So let's at
least hear the question, and then we can move forwards from there, OK?
Jul 21 '05 #3
*JimO* <jo********************@earthlink.net>:

Is there a way, or a better control, method, to
prevent user from entering text?


: 17.12 Disabled and read-only controls

--
If you make people think they're thinking, they'll love you.
If you really make them think, they'll hate you.
Jul 21 '05 #4
I actually didn't look at the code. After reading Darin's message, I looked
a few things up and got some working code using overflow-y and overflow
properties. It works in both IE and Mozilla. I'm not sure how well it'll
work when they stick it in there. I'm just getting a handle on this myself
as a later post will reveal. I know there's a way to lock out users using
textboxes in compilable languages. I didn't know if there was a direct way
to do that using javascript or some other technology. I guess the question
is what is the best way to allow a user to read text that scrolls and not
allow them to change the text inside? I think I answered my own question.
If there is a better way, or a programable way, I'd love to hear it. Here
is the code I used...

<style type="text/css" media="all">
<!--
p {
width: 200px;
background-color: lightgrey;
color: #A52442;
height: 500px;
font-size: 1.3em;
text-align: justify;
float: left;
padding: 15px;
overflow-y: scroll;
overflow: scroll;
}
div#clleft {
clear: left;
}
-->
</style>

Thanks,
Jim

"Alan J. Flavell" <fl*****@ph.gla.ac.uk> wrote in message
news:Pi*******************************@ppepc56.ph. gla.ac.uk...
On Tue, 22 Feb 2005, JimO wrote:
I teach HS computers and one of my kids has a web site with a
textbox of info that the user can scroll down and read.


If you're referring to a forms textarea, then that's precisely what it
was designed for.
The problem is that users can also enter text into it.


No, that's not the problem. The /problem/ is that it's being misused
for something that it wasn't intended for.
Is there a way, or a better control, method, to prevent user from
entering text?


Probably, What, actually, are you (or they) trying to achieve?
The crystal ball is cloudy, and there's no extra charge for telling
usenet - a bit more clearly - what the real-world problem is (in
preference to telling them what the failed solution was, and leaving
them to try and guess what the actual problem was, I mean)

Maybe <object...> or even (shudder) <iframe...> was what was intended?
But, if that was the answer (given the current browser support etc.),
there could have been something wrong with the question. So let's at
least hear the question, and then we can move forwards from there, OK?

Jul 21 '05 #5
Within the textarea tag set the "readonly" attribute.

--
Tony Marston

http://www.tonymarston.net
"JimO" <jo********************@earthlink.net> wrote in message
news:y0*****************@newsread3.news.pas.earthl ink.net...
I teach HS computers and one of my kids has a web site with a textbox of
info that the user can scroll down and read. The problem is that users
can
also enter text into it. Is there a way, or a better control, method, to
prevent user from entering text?

Thanks,
Jim

Jul 21 '05 #6
That's a much better solution to give the kids. They liked the CSS today
but I doubt they really understood it. The readonly attr is much more
direct.

Thanks

"Tony Marston" <to**@NOSPAM.demon.co.uk> wrote in message
news:cv*******************@news.demon.co.uk...
Within the textarea tag set the "readonly" attribute.

--
Tony Marston

http://www.tonymarston.net
"JimO" <jo********************@earthlink.net> wrote in message
news:y0*****************@newsread3.news.pas.earthl ink.net...
I teach HS computers and one of my kids has a web site with a textbox of
info that the user can scroll down and read. The problem is that users
can
also enter text into it. Is there a way, or a better control, method, to prevent user from entering text?

Thanks,
Jim


Jul 21 '05 #7
Thanks for everyone's input.
Jim
"JimO" <jo********************@earthlink.net> wrote in message
news:y0*****************@newsread3.news.pas.earthl ink.net...
I teach HS computers and one of my kids has a web site with a textbox of
info that the user can scroll down and read. The problem is that users can also enter text into it. Is there a way, or a better control, method, to
prevent user from entering text?

Thanks,
Jim

Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pamela Chatterjee | last post by:
In my Web Form I have more than one Textbox for user input. If I hit enter to any Textbox its submitting the form. How can I prevent Form submission if users hit enter to the textbox? I want to...
2
by: Danny | last post by:
I have a combo box look up and list items in a table, it is not bound. It works fine but how can I prevent the users from entering in there own data? i have an 'on change' event that when it...
9
by: Li Pang | last post by:
I use a combobox control to populate the data. I want to prevent to change data (freeze the data in the filed). The only solution I have is to set Enabled property to "False", but it gray out the...
14
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36)...
5
by: cameron | last post by:
I am working on an assignment where I have to allow end-users to enter in data and to have C++ make a calculation. From there I have to set up a loop to allow users to go back and enter new data or...
5
by: rn5a | last post by:
A Web Form has a TextBox within a DataGrid wherein users are expected to enter only whole numbers. It should be validated so that the TextBox doesn't remain blank or any non-numeric data is...
2
by: AjitGoel | last post by:
Hi; I need to create a custom textbox control which will not allow a user to paste text from the clipboard. The user has to always type the text into the textbox. I tried searching on the...
3
by: GarryJones | last post by:
I found this handy little script on the net that means the user can only press backspace or numbers in form input. <script type="text/javascript"> function numbersonly(e){ var...
6
by: robintwos | last post by:
Hi I would like to validate the while entering the data in a textbox for numeric values. it means . i would like to throw an error message when the user enters a character value. validation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.