www.webdeveloper.com
Results 1 to 4 of 4

Thread: Leaves space in input field

  1. #1
    Join Date
    Oct 2007
    Posts
    231

    Leaves space in input field

    I have a problem. I don't want to leave blanks in input as shown below:

    Display from Input element:
    Should be -> |Mickey|
    Comes up -> |Mickey |
    Which leaves some trailing blank.


    Sample code below:

    <html>
    <head>
    <script type="text/javascript">
    function maxLen()
    {
    var txt="Size=" + document.getElementById("name").size;
    var txt=txt + " and Max length=" + document.getElementById("name").maxLength;
    alert(txt);
    }
    </script>
    </head>
    <body>

    <form>
    Name: <input type="text" id="name" value="Mickey" size="6" maxlength="6" />
    <br /><br />
    <input type="button" onclick="maxLen()" value="Alert size and maxLength" />
    </form>

    </body>
    </html>

    Thanks.

  2. #2
    Join Date
    May 2004
    Location
    FL
    Posts
    3,447
    How about something like this? (I just googled "javascript 'remove space' forms)
    Lee

    ""Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."" -- Sir Winston Churchill

  3. #3
    Join Date
    Oct 2007
    Posts
    231
    That code wouldn't work. Let's say if I have "Mickey Mouse" and JS returns "MickeyMouse" which removes all blanks.

    This is what I want:

    Now shows: |Mickey.....| ...... are blanks (about 5 blanks).
    Should be " |Mickey| size=6, maxlength=6.

    Thanks.

  4. #4
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles