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 in CFTEXTINPUT.

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. For a complete list of validation formats, refer to the CFML Language Reference.

<BR>Please enter a date:
<CFFORM NAME="Form1"
    ACTION="cfform_submit.cfm"
    METHOD="Post">

    <CFTEXTINPUT NAME="entertext"
        VALUE="mm/dd/yy"
        MAXLENGTH="10"
        VALIDATE="date"
        FONT="Trebuchet MS">

    <BR>

    <INPUT TYPE="Submit"
            VALUE="Submit">

</CFFORM>

CFTEXTINPUT form variable

The value of the form variable passed from a CFTEXTINPUT control to a ColdFusion application page is determined by the entry in the CFTEXTINPUT control. The form variable is passed as:

textinput_name=textinput_value

In the example just above, the form variable would have been passed as:

entertext=textinput_value

So in the destination application page, the form variable is referenced as #entertext#