Results 1 to 2 of 2

Thread: Determining position of text in input field

  1. #1
    Join Date
    Jun 2008
    Posts
    187
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Determining position of text in input field

    Hello,

    I'm creating a customized search input field that takes text on the left side and search tags on the right:

    Click image for larger version. 

Name:	text up to tags.jpg 
Views:	61 
Size:	6.3 KB 
ID:	6218

    I want to limit the text to whatever will fit into the left side such that the user cannot type into the space occupied by the tags. For example, in the image above, the user can type:

    "This is some text. This is more text. Man, there's a lot of text here. Just look"

    before hitting the left-most tag "MECXXX". At that point, I want to prevent the user from typing anymore.

    But if the user gets rid of the "MECXXX" tag, he should be able to type some more:

    "This is some text. This is more text. Man, there's a lot of text here. Just look at all this text"

    Click image for larger version. 

Name:	more text up to tags.jpg 
Views:	54 
Size:	6.3 KB 
ID:	6219

    I can figure out the position of the left edge of the left-most tag, but how do I figure out the position of the right edge of the text?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,372
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    I think that you will just have to use trial and error to determine the max number of characters that will fit in each situation and have your code set the maxlength attribute of the text field accordingly.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Replies: 2
    Last Post: 12-15-2010, 12:26 PM
  2. Enabling a text field using a <SELECT> input
    By junestag in forum JavaScript
    Replies: 2
    Last Post: 11-20-2009, 08:36 PM
  3. Replies: 3
    Last Post: 05-16-2008, 04:05 AM
  4. Clear Default Text from Input field
    By tonyking in forum JavaScript
    Replies: 15
    Last Post: 03-31-2008, 07:03 PM
  5. Replies: 11
    Last Post: 10-24-2007, 11:35 PM

Bookmarks

Posting Permissions

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