University of Melbourne home page
 

Text input

The most common and basic form field. Use this field when you want a short, text answer.

Syntax

The actual field is an input tag of type text. The name attribute is required for the form processing script to label and identify the input text.

<input type="text" name="q01" />

Sample

To comply with accessibility guidelines, the field must be explicitly and uniquely identified and labeled, and to work with the template style sheets, some spans and classes must be added.

<label for="q01">
    <span class="question">Insert text here:</span>
    <span class="answer"><input type="text" id="q01" name="q01" /></span>
</label>

Example


Validation

To enable validation for this type of field you need to add the required class to the label and a span of class required-flag to the question span.

<label for="q01" class="required">
    <span class="question">Insert text here <span class="required-flag">(required)</span>:</span>
    <span class="answer"><input type="text" id="q01" name="q01" /></span>
</label>

valid email address

The validator can check for a correctly formed email address and will display an appropriate message. To enable this check you need to add the email class to the input.
Note: this does not check whether an email address is correct, just that it conforms to the expected aaa@bbb.cc format of email addresses.

<label for="q01" class="required">
    <span class="question">Insert text here <span class="required-flag">(required)</span>:</span>
    <span class="answer"><input type="text" id="q01" name="q01" class="email" /></span>
</label>

valid number

The validator can check that the input is a number and will display an appropriate message. To enable this check you need to add the number class to the input.
Note: this check allows whole numbers, floating points and negative numbers.

<label for="q01" class="required">
    <span class="question">Insert text here <span class="required-flag">(required)</span>:</span>
    <span class="answer"><input type="text" id="q01" name="q01" class="number" /></span>
</label>
 
html/forms/library/text_input.txt · Last modified: 2007/09/11 15:36 by aharris
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki