Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Locking a text field in Javascript


Message #1 by "Karry Dayton" <alichin@h...> on Thu, 26 Apr 2001 18:51:19
Read only is a newish attribute - I think that it is either in HMTL 4 
or IE, so is not currently a good solution for all users.

> -----Original Message-----
> From: aalbetski@t... [mailto:aalbetski@t...]
> Sent: 27 April 2001 16:56
> To: javascript@p...
> Subject: [javascript] RE: Locking a text field in Javascript
> 
> 
> you should be able to use the readonly attribute:
> 
> <input type="text" name="T1" size="20" readonly="true" 
> value="you can't
> change me">
> 
> -----Original Message-----
> From: Gregory_Griffiths@c...
> [mailto:Gregory_Griffiths@c...]
> Sent: Friday, April 27, 2001 11:28 AM
> To: javascript
> Subject: [javascript] RE: Locking a text field in Javascript
> 
> 
> try setting a variable somewhere and then doing :
> 
> onFocus="if (readonly==1){blur();}"
> 
> setting the value of READONLY to 1 will enable the readonly on this 
> field. If you have several fields like this, you could set up a 
> function to handle this.
> 
> > -----Original Message-----
> > From: alichin@h... [mailto:alichin@h...]
> > Sent: 27 April 2001 16:05
> > To: javascript@p...
> > Subject: [javascript] RE: Locking a text field in Javascript
> > 
> > 
> > I also know about the onfocus="blur();", what I'm trying to 
> > do is change 
> > it IN the Javascript.  For instance: 
> > 
> > if (document.form.checkboxone.value=="on")//Someone has 
> > clicked a checkbox
> > document.form.textfield.?? //what ever would lock this text field.
> > 
> > Thank you for your reply,
> > 
> > Karry
> > 
> > > onfocus="blur();"
> > > 
> > > -----Original Message-----
> > > From: Karry Dayton [mailto:alichin@h...]
> > > Sent: Thursday, April 26, 2001 2:51 PM
> > > To: javascript
> > > Subject: [javascript] Locking a text field in Javascript
> > > 
> > > 
> > > Is there a way to lock a text field so that it can't be 
> edited via 
> > > javascript, i.e. this.form.somefield.locked=rue or 
> > something like that.  
> > I 
> > > know how to do it by saying the field is 'readonly' but I 
> > want to be 
> > able 
> > > to have a checkbox that if checked locks the form from 
> > further changes.  
> > > 
> > > Thank you,
> > > 
> > > Karry
> > > 
> > 

  Return to Index