473,774 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Test if text box is readonly

<input type="text" name="actreqto" maxlength="20" value=""
onkeypress="cha ngedDetails();" onchange="chang edDetails();"
readonly="reado nly">

Any ideas why doesn't this work?

alert(top.docum ent.forms[0].actreqto.reado nly);

displays 'undefined'

alert(top.docum ent.forms[0].actreqto.reado nly=='readonly' );

displays 'false'

thanks

harry
Jul 23 '05 #1
4 11313
On Sun, 16 May 2004 08:57:06 GMT, harry wrote:
<input type="text" name="actreqto" maxlength="20" value=""
onkeypress="cha ngedDetails();" onchange="chang edDetails();"
readonly="reado nly">

Any ideas why doesn't this work?

alert(top.docum ent.forms[0].actreqto.reado nly);
alert(top.docum ent.forms[0].actreqto.readO nly);
alert(top.docum ent.forms[0].actreqto.reado nly=='readonly' );


readOnly is a boolean.

--
C'ya,
ZER0 :: coder.gfxer.web Designer();

"When you have eliminated the impossible, whatever remains,
however improbable, must be the truth." (S.H.)
Jul 23 '05 #2
Thanks for that Zero, was hoping to test if a key was pressed in a text box
that has readOnly set.

Any ideas why this returns false regardless of this setting?
function changedDetails( )
{
alert(this.read Only==true);
..
..
..
}

cheers

"ZER0" <ze********@lib ero.it> wrote in message
news:ms******** ******@ID-171124.news.ind ividual.net...
On Sun, 16 May 2004 08:57:06 GMT, harry wrote:
<input type="text" name="actreqto" maxlength="20" value=""
onkeypress="cha ngedDetails();" onchange="chang edDetails();"
readonly="reado nly">

Any ideas why doesn't this work?

alert(top.docum ent.forms[0].actreqto.reado nly);


alert(top.docum ent.forms[0].actreqto.readO nly);
alert(top.docum ent.forms[0].actreqto.reado nly=='readonly' );


readOnly is a boolean.

--
C'ya,
ZER0 :: coder.gfxer.web Designer();

"When you have eliminated the impossible, whatever remains,
however improbable, must be the truth." (S.H.)

Jul 23 '05 #3
On Mon, 17 May 2004 10:33:49 GMT, harry wrote:
Thanks for that Zero, was hoping to test if a key was pressed in a text box
that has readOnly set.

Any ideas why this returns false regardless of this setting?


Yes. Because the "this" keyword in that context is NOT your HTML input
object.

Try this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html>
<head>
<title></title>
</head>

<body>
<script type="text/javascript">
function changedDetails( sender){
if (sender.readOnl y)
alert("the element "+sender.na me+" is readonly");
else
alert("the element "+sender.na me+" is editable");
}
</script>

<input type="text" name="actreqto" maxlength="20" value=""
onkeypress="cha ngedDetails(thi s);" readonly="reado nly" />

</body>
</html>
--
C'ya,
ZER0 :: coder.gfxer.web Designer();

"Nei film americani, qualsiasi problema che venga considerato
sufficientement e catastrofico, puo' essere risolto facendo esplodere uno
o piu' ordigni nucleari" (ZER0 & Cosimo)

Now playing: "No more chances"
Jul 23 '05 #4
Excellent! works perfectly - thanks again!

"ZER0" <ze********@lib ero.it> wrote in message
news:hc******** ******@ID-171124.news.ind ividual.net...
On Mon, 17 May 2004 10:33:49 GMT, harry wrote:
Thanks for that Zero, was hoping to test if a key was pressed in a text box that has readOnly set.

Any ideas why this returns false regardless of this setting?


Yes. Because the "this" keyword in that context is NOT your HTML input
object.

Try this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html>
<head>
<title></title>
</head>

<body>
<script type="text/javascript">
function changedDetails( sender){
if (sender.readOnl y)
alert("the element "+sender.na me+" is readonly");
else
alert("the element "+sender.na me+" is editable");
}
</script>

<input type="text" name="actreqto" maxlength="20" value=""
onkeypress="cha ngedDetails(thi s);" readonly="reado nly" />

</body>
</html>
--
C'ya,
ZER0 :: coder.gfxer.web Designer();

"Nei film americani, qualsiasi problema che venga considerato
sufficientement e catastrofico, puo' essere risolto facendo esplodere uno
o piu' ordigni nucleari" (ZER0 & Cosimo)

Now playing: "No more chances"

Jul 23 '05 #5

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

Similar topics

5
2852
by: Art | last post by:
Hi, I'm using a form text input to display a JavaScript clock. It has no other purpose than that, just show the date and time. What I would like to do now is prevent anything else happening when it's moused over. I was able to remove the cursor using the blur() method, something like this: document.formname.inputname.blur();
3
2214
by: Roy Adams | last post by:
Hi I'm reposting this question because for some reason can't post follow up question to this thread. What I'm trying to do is put the value and text from a a select in to a text field and to a hidden field respectfully and the value from dynamically created hidden fiields in to a text fieldin to a text field all at the same time Here's the code as viewed through the browser <body bgcolor="#FFFFFF" text="#000000" > <SCRIPT...
5
5639
by: Randell D. | last post by:
Folks, I have a few <INPUT TYPE=TEXT> tags that are readonly if a specific field has no value... these work fine. However, I also have checkboxes which I would like to have as readonly, but the same code doesn't work - Can someone suggest a solution? This is sample code extracted from my original code: // Before other input tags determine if they are read only or not,
35
2584
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C# newsgroup on 25 September. The regular expressions where in that newsgroup too involved. I told yesterday night, to Jay that I would test all 4 methods and the stupid method I was thinking of the first time that night when I saw Jon's
0
2437
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
3
2664
by: jonniethecodeprince | last post by:
Hi all, I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file. There are 50 Records in this file. There are 5 colums of data I wish to display. I want to display these records in groups of 10. Based on the fact that the records I want are located in a separate file, how can I get these details to show on the form and manipulate the data to...
2
1870
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2 for a windows application. I have a richtextbox control on my form that I make it readonly. 1. Do I need to make readonly to be false to append text to it? 2. Even though I chose the Cursor property of the richtextbox to be "No" but when I run the application I can still click on the RTB and got a Ibeam cursor among my text. Is there a way to prevent a user being able to click on the text and get the ibeam...
7
3133
by: kirkgilbert | last post by:
I am trying to do an onchange event in a form using a text field. The form is tied to a record set that is part of a repeated region. One the first record when I edit the data it works perfectly. When I go to the second record nothing happens. I have attached the code below: I bolded text that contains the javascript and fields this is applied to <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/FutureOrders.asp"...
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.