Textual Input

The cftextinput tag offers a Java control for accepting basic text input. Although it provides the same basic functionality as the cfinput and HTML input tags, cftextinput differs in that it allows you to specify a number of attributes affecting the look of both the text box and the data entered into it. Consider Example 10-5, in which two cftextinput tags are used to solicit information from a user.

Example 10-5. Creating a form using cfform and cftextinput

<!--- Check to see if form field data is being passed and if so, display it ---> <cfif IsDefined('form.Fieldnames')> <h3>You submitted:</h3> <cfoutput> MyName: #form.MyName#<br> PhoneNumber: #form.PhoneNumber# </cfoutput> <hr noshade> </cfif> <cfform action="#CGI.Script_Name#" enablecab="Yes" name="MyForm" enctype="application/x-www-form-urlencoded"> <table> <tr> <td>Name:</td> <td><cftextinput name="MyName" align="AbsMiddle" height="25" width="250" bgcolor="##C0C0C0" font="Arial" fontsize="14" bold="Yes" italic="No" textcolor="##000000" maxlength="255" required="Yes" message="You must enter your name"></td> </tr> <tr> <td>Phone Number:</td> <td><cftextinput name="PhoneNumber" value="xxx-xxx-xxxx" align="AbsMiddle" height="25" width="100" bgcolor="##C0C0C0" font="Arial" fontsize="14" bold="Yes" italic="Yes" textcolor="##000000" maxlength="12" required="Yes" validate="telephone" message="You must enter your phone number as xxx-xxx-xxxx"> </td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="submit"></td> ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.