This is an archive of an inactive wiki and cannot be modified.

Replace free text input in forms with list boxes (in XHTML Basic and in XHTML MP, implemented by select and option elements) when data entered in the text input belongs to a set of know values.

For example, in XHTML Basic, if you have to enter the name of a Spanish province in a form, do not use a text input:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
    "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Example of free text input</title>
   </head>
   <body>
      <p>
        <label for="txtSpanishProvince">Province:</label>
      </p>
      <p>
        <input class="input" type="text" title="Enter a Spanish province" 
               name="txtSpanishProvince" id="txtSpanishProvince" value="" />
      </p>
   </body>
</html>

And use a select element with option children instead:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
    "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Example avoiding free text input</title>
   </head>
   <body>
      <p>
        <label for="ddlSpanishProvince">Province:</label>
      </p>
      <p>
        <select title="Please choose a Spanish province" name="ddlSpanishProvince" id="ddlSpanishProvince">
            <option value="">Please Select ... </option>
            <option value="Alicante">Alicante</option>
            <option value="Asturias">Asturias</option>
            <option value="Madrid">Madrid</option>
            ...
        </select>
      </p>
   </body>
</html>


CategoryBpAvoidFreeText

Contributions to this wiki are governed by the W3C policies for Contribution to W3C' wiki on Mobile Web.