Contact Our Development Team
Free Code Tutorials & Open Source Code
HTML Forms - Text
Tutorials > HTML > Forms > Text
Textfields
Text fields are small rectangular boxes which should be used for the user to input short strings of text: for example a search box, or entering a user name. Text fields are created by setting the type attribute of input, to <input type="text" />, and there are a number of additional attributes which can be set. As explained in our inputs tutorial, these are normally processed using a server-side scripting language such as PHP - so don't worry about the processing yet. Here are some examples:
<input type="text" />
Textfield Size
Using the size="" attribute, you can specify how big your textbox is.
<input type="text" size="10" /><br />
<input type="text" size="20" /><br />
<input type="text" size="30" /><br />



Preset Textfield Values
<input type="text" value="textfield" />
Textfield Maxlength
You can use the maxlength="" attribute to set the maximum number of characters which can be entered into a text box. You should note that while this can add some functionality for users, it can be easily be bypassed by malicious users, so you should be sure not to rely on it as a security measure; we'll look at how to enforce string lengths using PHP later in our tutorials.
<input type="text" size="10" maxlength="5" value="enter" /><br />
<input type="text" size="20" maxlength="10" value="enter some" /><br />
<input type="text" size="30" maxlength="20" value="enter some text" /><br />



Page Responses
Currently there have been no responses to this page...
If you have anything to contribute to this tutorial, found a bug, or know a better way of achieving the same goal, please leave your response below.
     
Copyright ©2009, Wired IDS Ltd. | Licensed under Creative Commons Attribution Share-Alike | Load time: 0.2967 seconds