Click to See Complete Forum and Search --> : Max length


jgbarber65
06-11-2006, 09:09 PM
On my web site, people can place a small ad that fits in predefined sized cell in a table. The ad is made up of 16 Max characters at font size 3 for the title and then 6 rows of approximately 31 characters per row for the body. When they submit the 6 rows x 31 char ad, I have a multiline text area set up for them to type into and I have it set so that it wraps at 31 characters and I set the max length to 186 characters.

My question is in two parts.

1) I noticed that the max length is not working. It wraps properly at 31 characters, but I can enter unlimited # of characters. How do I set the max number of characters allowed? I am using Frontpage by the way.

2) I am using the Arial font. I know for something like this Courier or a fixed width font woud work better, but I want to use Arial. If someone enters ad text that contains a lot of capital W's as opposed to text that contains a lot of lower case i's, they obviously cannot enter as many characters. Is there a way to calculate a non-fixed width font to determine if an ad would fit in the allowed cell size? I do not want to make my cell sizes resizable. I want all cell sizes to to be the same.

I guess if I get #1 solved, I won't have to worry about #2, but I would still like to know how to do this.

Thanks,
Joe

NogDog
06-11-2006, 10:38 PM
The maxlength attribute does not apply to textareas, only to text-type input elements. If you want to use a textarea, then you'll have to add your own validation on the server side that validates the number of characters and generates an error if they exceed it. (You could also add local validation with JavaScript, but you need the server-side validation for users who have JS disabled.) Alternatively, you could create one input element for each row, with a maxlength attribute of 31 (or whatever value you want to use).