Building Text Entry Boxes

The cftextinput tag is similar to the HTML input=text tag. With cftextinput, however, you can also specify font and alignment options, as well as enable input validation methods using either a JavaScript or the validate attribute.

The following example shows a basic cftextinput control. This example validates a date entry, which means that a user must enter a valid date in the form mm/dd/yy (the year can be up to four digits). For a complete list of validation formats, see the CFML Reference.

Please enter a date:<br>
<cfform name="Form1"
  action="submit.cfm"
  method="Post">

  <cftextinput name="entertext"
    value="mm/dd/yy"
    maxlength="10"
    validate="date"
    font="Trebuchet MS">
  <br>
  <br>
  <input type="Submit"
      value="Submit">

</cfform>

To get the value of the input text in the action page, use the variable Form.textinput_name; in this case, Form.entertext.