Solved

Text Overflow Property (elipse) in IE6 Input Field

Posted on 2009-07-01
2
1,372 Views
Last Modified: 2013-12-08
I am trying to implement Text Overflow in an Input field and having no luck.  Using the code below

It does not work.  However the same exact tags work if I make type = "button", and the white-space/text-overflow/overflow combination creates the required ellipses in a DIV or a TD

Anyone able to point me in the right direction for a truncated text field (using IE 6) that will replace overflowed text with an ellipse?  
<input type = "text" id="Text2"  style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display:inline-block; width: 145px; height: 25px;" />

Open in new window

0
Comment
Question by:thearniec
2 Comments
 
LVL 13

Accepted Solution

by:
Murali Murugesan earned 300 total points
Comment Utility
I dont think text-overflow property would be applicable for text box. Here is how u can acheive the same through javascript

<input type = "text" id="Text2"  style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display:inline-block; width: 145px; height: 25px;" onkeydown="ellipsis(this.value,10);"/>

function ellipsis(txtValue,allowedwidth){
      var ellipsis_s = "...";
      if(txtValue.length == allowedwidth){
            document.getElementById('Text2').value = txtValue.substr(0,allowedwidth)+ ellipsis_s;
            document.getElementById('Text2').maxLength=txtValue.length;
      }else if(txtValue.length > allowedwidth +ellipsis_s.length){
            if(txtValue.substr(0,txtValue.length -1).length > allowedwidth){
                  document.getElementById('Text2').value = txtValue.substr(0,txtValue.length -1);
            }            
      }
}

-Murali*
0
 
LVL 12

Assisted Solution

by:Chad Haney
Chad Haney earned 200 total points
Comment Utility
There is no attribute to set this for an input box, using javascript is going to be your only option in this case.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now