• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is the minimum size of a text box?

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am using JSF 2 & Richfaces 4

My input text box should accept only 1 character.
<h:inputText id="empid" value="#{details.val}" size="1" />

Set the size as 1, still it showing more size in the screen.
Apart from size =1, any other place to set the size of the text box?
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same as the regular HTML control that the h:inputText control is based on. "maxlength".

Size specifies how many character-widths wide the box should be. These days, it's probably better to do that via CSS.

maxlength specifies how many characters you can enter in the box.
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

Textbox should accept 1 character. That is handled in maxlength.
But text box size should also having length of 1 character only.
Currently it is showing length as more than 1 character.

How to handle this one.
Please help.
 
Tim Holloway
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "size" attribute computes an estimated width, but it is not a very accurate one one any of the systems I've worked on.

A more precise control can be used by adding a CSS width attribute.

For example:


A width of 1 "em" is the width of a single letter "m" using the font that renders the text being input. This will usually be slightly larger than a numeric digit unless you are using a mono-spaced font, which by definition has all characters the same width. Most fonts use the same width for all digits, by the way. The letter "m" is typically the widest character in the font, although in some cases a "w" may be wider.

For best results, study up on the CSS metric options and pick whatever pleases you most.
 
reply
    Bookmark Topic Watch Topic
  • New Topic