Web Analytics Made Easy -
StatCounter READONLY attribute of input textbox doesn't work in Netscape 4x - CodingForum

Announcement

Collapse
No announcement yet.

READONLY attribute of input textbox doesn't work in Netscape 4x

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • READONLY attribute of input textbox doesn't work in Netscape 4x

    I have the following input text box:

    <input TYPE="TEXT" NAME="org_code" VALUE="" READONLY MAXLENGTH=25 SIZE=25>

    This works in IE, but not in Netscape 4.75. In netscape, I can modify what is in the input text box. Is there a workaround for this?

  • #2
    i think readonly is one of those microsoft only things. try using "disabled" instead
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

    Comment


    • #3
      <html>
      <head>
      <title>untitled</title>
      <script type="text/javascript" language="JavaScript">

      function toggle_readonly(control) {
      if (typeof control.readOnly != 'undefined')
      control.readOnly = (control.readOnly) ? false : true;
      else if (control.onfocus != null) control.onfocus = null;
      else control.onfocus = function() { this.blur() };
      }

      </script>
      </head>
      <body>
      <form>
      <input type="text" name="org_code" size="25" maxlength="25" readonly="readonly"
      onfocus="if(typeof this.readOnly=='undefined')this.blur()"><br>
      <input type="button" value="Toggle Readonly" onclick="toggle_readonly(org_code)">
      </form>
      </body>
      </html>

      Comment


      • #4
        This also works...

        <form>
        <input type="text" value="blah" onchange="this.value=this.defaultValue" />
        </form>
        Former ASP Forum Moderator - I'm back!

        If you can teach yourself how to learn, you can learn anything. ;)

        Comment


        • #5
          yo whammy...

          Your alternative has a problem - the field reverts after it loses focus, possibly leaving the user thinking the change has been made.

          Comment


          • #6
            True... but it does work (at least in NS 4.7 which I have installed)! It also works well in combination with other methods like "readonly" or "disabled"...

            Of course you could also use onkeyup, onkeydown, onkeypress, onblur, etc. depending on the browser and what you want to do... or even an alert box, like:

            <form>
            <input type="text" value="blah" onchange="alert('Yo! Don\'t be changin\' this!'); this.value=this.defaultValue" />
            </form>

            I know you're well aware of this, adios, since you're still a couple of light-years ahead of me in javascript programming (and you have taught me a lot)... I'm just putting in my two cents worth.

            But the main thing I'm assuming is that if you don't want the value of the text field changed (since he originally had it disabled), then you don't really care what the user has typed in anyway... right?

            Last edited by whammy; Jul 2, 2002, 08:10 PM.
            Former ASP Forum Moderator - I'm back!

            If you can teach yourself how to learn, you can learn anything. ;)

            Comment


            • #7
              I always turn to Jukka "Yucca" Korpela in cases like this:

              http://www.cs.tut.fi/~jkorpela/forms/readonly.html

              Thanks for the comps....

              Comment


              • #8
                thanks!

                Thanks adios and whammy. It's always good to know a couple ways to do the same thing.

                I'm learning a lot already.

                Comment

                Working...
                X