Typically a form will require details like first and last name, city, address, postal code, etc. Let’s start by asking for the person’s city of residence. Our question to the user - what we want the user to read - goes inside a <label> tag. The part of the form that they will fill out is created, in this case, by an <input /> tag. (Note that <input /> tag is, like the <img /> tag, is closed inside itself, as it creates its own content, and does not surround anything. For most text input we require the type attribute of the <input> tag to be set to "text". (In this case, “text” means alphanumeric characters: a textbox like this can be used to receive numbers and letters equally. This is improved, and made far more explicit and precise, in HTML 5 forms).
- <label>City</label>
- <input type=“text” name=“city” id=“city” />
Note that the name attribute is not related to anything in the text box itself: it is simply the name associated with the input, for the purpose of PHP. (id is set to the same value as name. id is referenced by JavaScript, HTML, and CSS). The name must be a unique word, following strict web naming conventions.
The size attribute determines how large the textbox appears on the screen: it literally limits how many characters can appear in its “window”. Set the size to a reasonable amount (approximately 25 for anything other than addresses or specialized entry areas).
The maxlength attribute is the final attribute required for this tag. It should be two less than the size to give space to see all the characters placed into the textbox, otherwise some the first few characters typed in will tend to be cut off as maxlength is approached.
So our line of code now becomes:
- <label>City</label>
- <input type=“text” name=“city” id=“city” size=“32” maxlength=“30” />
so we don't need the jQuery minimum length anymore:) cool!


