View Full Version : How To Define Width Of Field In Form?
digitalpoint
Jun 7th 2004, 9:03 am
I know you can use the normal size attribute, but is there any way (with CSS maybe) to define it a little more exact (for example with a px number? The reason I ask is it's really ugly when you have one long field, with two smaller ones on the next row, but no matter what size values you use, they can never be the same total width.
rocky
Jun 7th 2004, 9:12 am
try adding this to the tag:
style="width: 200px;"
Razvan Pop
Jun 7th 2004, 9:43 am
input {
width: 200px;
}
Will make all your <input /> fields 200px wide.
textarea {
width: 200px;
}
Will make all your <textarea></textarea> fields 200px wide.
digitalpoint
Jun 7th 2004, 10:01 am
Awesome, that's exactly what I was looking for, thanks. :)
Razvan Pop
Jun 7th 2004, 10:05 am
MORE:
you have the CSS for input and textarea. Let's say you want the buttons look different.
<input type="submit" value="submit" class="buttons" />
the CSS:
input.buttons {
width: 100px;
background-color: red;
}
rfuess
Jun 11th 2004, 12:59 am
Although the "size" attribute may not get the precision of the "width" style attribute, remember that it is not supported in some older browsers.
In these cases, it will use the default size, regardless of the width you put in the style tag.
However, most browsers nowdays support this.
Robert Fuess
Spiderweb Logic
CollectionDX
Jun 14th 2004, 11:59 am
Related to this - is there any way to put a maxlength on a multi-line textarea? I know you can for a regular form field.
Thanks.
rfuess
Jun 16th 2004, 12:05 am
Perhaps wire an "onchange" javascript function . . .
When the text changes
1) check the length
2) if > max, truncate to max
3) put cursor at end of field
mykoleary
Oct 9th 2004, 1:43 am
Perhaps wire an "onchange" javascript function . . .
When the text changes
1) check the length
2) if > max, truncate to max
3) put cursor at end of field
You're better off popping an alert saying the limit and how long the field is, the person may want to cut out text from the beginning to fit the limit as opposed to the text you arbitrarily chopped off of the end.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.