user input box: first 2 characters as a read only value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • reneeccwest

    #1

    user input box: first 2 characters as a read only value

    <input type="text" size="7" name="test" maxlength="4" value="4Tyourna me">

    Is there any way I can make first 2 characters as a read only value?
  • Vjekoslav Begovic

    #2
    Re: user input box: first 2 characters as a read only value

    "reneeccwes t" <reneeccwest@ho tmail.com> wrote in message
    news:9f9d6d21.0 309050953.43309 c2d@posting.goo gle.com...[color=blue]
    > <input type="text" size="7" name="test" maxlength="4" value="4Tyourna me">
    >
    > Is there any way I can make first 2 characters as a read only value?[/color]

    Of course not, but you could simulate that strange behaviour, something like
    this:

    <input value="4T" size="2" style="margin-right:none; border-right:none;
    text-align:right;"
    onfocus="docume nt.getElementBy Id('yourname'). focus()"><input id="yourname"
    style="margin-left:none; border-left:none" value="yourname ">


    Comment

    • Grant Wagner

      #3
      Re: user input box: first 2 characters as a read only value

      reneeccwest wrote:
      [color=blue]
      > <input type="text" size="7" name="test" maxlength="4" value="4Tyourna me">
      >
      > Is there any way I can make first 2 characters as a read only value?[/color]

      If it really is read-only, then make it read-only:

      <style type="text/css">
      span.outline {
      font-family: monospace;
      border: 2px inset;
      }
      @media screen,print {
      span.outline {
      padding: 1px;
      }
      input.noBorder {
      font-family: monospace;
      border: none;
      }
      }
      </style>
      <form>
      <input type="hidden" name="testHidde n" value="4T">
      <span class="outline" >4T<input type="text" size="9" name="test" maxlength="8"
      value="yourname " class="noBorder "></span>
      </form>

      When the submitted data arrives at the server, concatenate the contents of
      testHidden and test together.

      Of course it doesn't look so hot in Netscape 4.x, but it's not completely
      unusable, and in more modern browsers you get a funky input box where the
      first two characters appear to be "read-only". The only browser I'm really
      disappointed at is Opera 7.11. It refuses to honor border:none on the input
      element.

      --
      | Grant Wagner <gwagner@agrico reunited.com>

      * Client-side Javascript and Netscape 4 DOM Reference available at:
      *


      * Internet Explorer DOM Reference available at:
      *
      http://msdn.microsoft.com/workshop/a...ence_entry.asp

      * Netscape 6/7 DOM Reference available at:
      * http://www.mozilla.org/docs/dom/domref/
      * Tips for upgrading JavaScript for Netscape 7 / Mozilla
      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


      Comment

      • reneeccwest

        #4
        Re: user input box: first 2 characters as a read only value

        Is it possible to remove the space from the left side?
        There is a space before "4T"

        "Vjekoslav Begovic" <vjbegovic@inet .hr> wrote in message
        news:bjar54$dv4 $1@sunce.iskon. hr...[color=blue]
        > "reneeccwes t" <reneeccwest@ho tmail.com> wrote in message
        > news:9f9d6d21.0 309050953.43309 c2d@posting.goo gle.com...[color=green]
        > > <input type="text" size="7" name="test" maxlength="4"[/color][/color]
        value="4Tyourna me">[color=blue][color=green]
        > >
        > > Is there any way I can make first 2 characters as a read only value?[/color]
        >
        > Of course not, but you could simulate that strange behaviour, something[/color]
        like[color=blue]
        > this:
        >
        > <input value="4T" size="2" style="margin-right:none; border-right:none;
        > text-align:right;"
        > onfocus="docume nt.getElementBy Id('yourname'). focus()"><input id="yourname"
        > style="margin-left:none; border-left:none" value="yourname ">
        >
        >[/color]


        Comment

        Working...