File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Field size Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Field size" Watch "Field size" New topic
Author

Field size

Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
How do I use Javascript/HTML to ensure the user doesnot enter more than 3 characters in a form field?
When we visit some websites, the form doesnot allow you to enter say the username- for more than 4 characters long.The cursor doesnot move forward.
How do we do that?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50677

Lucky, judging from the types of questions you are asking, you really need to get ahold of a basic HTML reference which could answer a lot of your questions.
One is available here. And if you look up the input tag, you will find that the maxlength attribute does exactly what you want.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: Field size
 
Threads others viewed
[Spring] One module in website development : Need your input
Encoding of special characters in the request parameter
Fixed size JTextField
Automatic Tab
want to show error message when illegal characters are entered in input fields
developer file tools