473,773 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A variation on the textbox length-checking dilemma

Hi :-)

I really did try to keep this short but I'm notoriously bad at writing
anything short, so...

Okay, so the situation is as follows: there's a page with a list of
textboxes (varying amount of them), and we want to control the length
of the text that goes into each of them (the textboxes all have the
same max size of content). I know, I know, it's been done in 50-
zillion ways already. But, our version has a twist!

You see, the data from these textboxes then fills some fields in PDF
forms. These fields are kinda like divs with a specific width and
height set - and we want to make sure that anything accepted by the
form will look good on the PDF form, that is, fit in those fields.

For the sake of the explanation, let's imagine we have a PDF field
that accepts 3 rows of text by 60 columns.

Consider the following text:
Lorem ipsum dolor sit amet. Consectetuer adipiscing elit,
maecenas ac magna a dolor iaculis pretium. Pellentesque
interdum. Nunc ut arcu. Proin porta feugiat urna.
This is roughly 162 characters, all in one long line that wraps into 3
lines. It'll be accepted by most any JavaScript textbox-length-
checker, and rightly so, since it'll look okay on the finished PDF.

Now, consider this text:
Lorem ipsum dolor sit amet.
Consectetuer adipiscing elit, maecenas ac magna a dolor
iaculis pretium.
Pellentesque interdum. Nunc ut arcu.
Proin porta feugiat urna.
This is the exact same text - so still 162 characters - but there's 3
newlines in it, which makes the text span 5 lines in all. We don't
want to accept this one, since it'll mess up the whole PDF form.

I know how I could write the code in PHP, but that's useless since I
want it to check the length _before_ the form content is submitted.
The problem is my knowledge of JavaScript is pretty much nonexistent -
I can change variables and stuff, but overall, I'm total rubbish at
it. Hence why I'm asking for help here.

Thanks in advance,

Alicja Z.
Nov 21 '07 #1
2 1384
In comp.lang.javas cript message <Qq************ *********@gigan ews.com>,
Wed, 21 Nov 2007 18:22:24, Randy Webb <Hi************ @aol.composted:
>
What you are going to have to do is reformat the text so that instead
of soft-wrapping you cause it to hard wrap. Then count the lines.
The OP can find such a reformatter in function Pak_ of
<URL:http://www.merlyn.demo n.co.uk/js-quick.htm>.

That recognises paragraphing, which the OP does not IIRC call for; but
if the OP wishes to preserve existing hard returns then the paragraph
handling needs to be changed to hard return handling.

If the OP had wished to deal with text by retaining all hard returns
without adding any wrapping, then a RegExp check would suffice.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 22 '07 #2
AsZe wrote:
You see, the data from these textboxes then fills some fields in PDF
forms. These fields are kinda like divs with a specific width and
height set - and we want to make sure that anything accepted by the
form will look good on the PDF form, that is, fit in those fields.
The aforementioned fact aside that counting characters alone will not help,
I don't think this can be done in general. PDF provides fully scalable
display and allows to specify and embed the font that is to be used; HTML,
by default, does not.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Nov 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
38201
by: Ramsin Savra | last post by:
Hi, What do you suggest to do if I want to do a search in TextBox ? I know that using RichTextBox, we could have Find method to search for a specific word or information but I was wonder if somebody knows some methods for Find and Replace in TextBox. Thanks
6
2238
by: Stuart Ferguson | last post by:
Is there a way from a textbox that you can establish the maximum length of the text that will be displayed in the textbox on the screen. What i am not requring is the Max Length of the Textbox but the Maximum Displayed Length. Any help is appreciated Stuart
9
10120
by: Jerry | last post by:
In limiting textbox input to 500 characters I would like to include a dynamic count of characters input while the user is typing into a textbox. This would obviously be a client side control, possibly a custom validator with a function written in javascript. Has anyone done this? Does someone have an example? Regards
2
1991
by: Peter | last post by:
I hate using the mask edit conrol so I created these two function to format my phone numbers. Is there a way to consolidate these two functions into one? In this example say the textbox you want to format is named "txtTest" I would format it in this fashion: in the onchange event: 'Formats the text on entry txtTest.text = FormatPhoneNumber(sender, txtTest.text)
0
11999
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the form controls so
8
5759
by: nil | last post by:
Hello all, It's urgent... i want to add autocomplete textbox facility in my application like google. as you type it suggests option to the user..i want the same kind of facility...i know i can do only with ajax(xml and javascript) but i want to fetch possible values from database and want to show as the user types in text box.
0
2400
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
1
2466
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name and its rate should come in the next two cells...it should take from the data base... it's my code........ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <%@ page import="java.sql.*"...
2
12945
by: mrutyunjaya | last post by:
hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass textboxid in javascript .my code is function validation() { alert("hi")
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.