Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / April 2004

Tip: Looking for answers? Try searching our database.

location of most recent character entered into textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom Wells - 02 Apr 2004 20:24 GMT
Is there a jscript function that can check the location of text in a textbox
to determine if the text is exceeding the display area of the textbox?  For
example: I have a textbox that has maxlength=20.  The textbox width is tied
to pixels and not characters so the textbox may be filled after only 15
characters.  If the user keeps typing the other 5 characters, the left end
scrolls of screen and is hidden.  If the form on the screen is printed then
the printed copy is missing text.  If the data is submitted and the same
form is used to display the results then data is hidden from the viewer so
they may approve or process information based on a false interpretation.
The data stored in the database should match the data displayed on the
screen.  The legal ramifications that could arise are astounding.  If anyone
has a solution for this bit of rampant stupidity from Microsoft I would sure
like to know.

Thanks,
Tom
bruce barker - 07 Apr 2004 17:16 GMT
no.  if its important to not truncate displayed text, don't use pixels, use
points.

-- bruce (sqlwork.com)

> Is there a jscript function that can check the location of text in a textbox
> to determine if the text is exceeding the display area of the textbox?  For
[quoted text clipped - 12 lines]
> Thanks,
> Tom
Lithium - 09 Apr 2004 13:21 GMT
why no --> read the dhtml reference

use createTextRange () and getClientRects() for IExplorer

example
<html><head>><title>Get TextBox Text Width</title></head><body><input id="test" onkeydown="change_YourInput_Width ();" type="text" size="10"></body><script
var YourInput=document.getElementById("test")

var YourInput_StartWidth=YourInput.offsetWidth

function change_YourInput_Width (
   
    var YourInput_TR=YourInput.createTextRange()
    var ClientRectangle=YourInput_TR.getClientRects ()
    var width=ClientRectangle[0].right-ClientRectangle[0].left+15
    if (width>=YourInput_StartWidth) YourInput.style.width=width
   
</script></html
bruce barker - 09 Apr 2004 22:57 GMT
the question was not which characters were selected, but rather which were
visible in the case where the textbox was not large enough to display all
the characters.

-- bruce (sqlwork.com)

> why no --> read the dhtml reference;
>
> use createTextRange () and getClientRects() for IExplorer;
>
> example:
> <html><head>><title>Get TextBox Text Width</title></head><body><input id="test" onkeydown="change_YourInput_Width ();" type="text"
size="10"></body><script>
> var YourInput=document.getElementById("test");
>
[quoted text clipped - 8 lines]
> }
> </script></html
Lithium - 10 Apr 2004 19:26 GMT
>the question was not which characters were selected, but rather which wer
>visible in the case where the textbox was not large enough to display al
>the characters

>-- bruce (sqlwork.com

Tom Wells question was
Is there a jscript function that can check the location of text in a textbo
to determine if the text is exceeding the display area of the textbox

and yes it is with getClientRects ()  you get a rectangle of the complete input value and with attributes right and left you ca
calculate the width and if the text width is bigger than the input clientWidth -
THE TEXT IS EXCEEDING THE DISPLAY AREA OF THE TEXTBOX
Tom Wells - 15 Apr 2004 22:28 GMT
Thanks guys! I'll give it a try and resolve this argument.
> >the question was not which characters were selected, but rather which were
> >visible in the case where the textbox was not large enough to display all
[quoted text clipped - 9 lines]
> calculate the width and if the text width is bigger than the input clientWidth ->
> THE TEXT IS EXCEEDING THE DISPLAY AREA OF THE TEXTBOX.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.