cftextinput

Description

Puts a single-line text entry box in a cfform tag and controls its display characteristics.

Category

Forms tags

Syntax

<cftextinput 
  name = "name"
  value = "text"
  required = "Yes" or "No"
  range = "min_value, max_value"
  validate = "data_type"
  onValidate = "script_name"
  message = "text"
  onError = "text"
  size = "integer"
  font = "font_name"
  fontSize = "integer"
  italic = "Yes" or "No"
  bold = "Yes" or "No"
  height = "integer"
  width = "integer"
  vSpace = "integer"
  hSpace = "integer"
  align = "alignment"
  bgColor = "color"
  textColor = "color"
  maxLength = "integer"
  notSupported = "text"> 

See also

cfapplet, cfform, cfgrid, cfgridcolumn, cfgridrow, cfgridupdate, cfinput, cfselect, cfslider, cftree, cftreeitem

Attributes

Attribute Req/Opt Default Description
name
Required
 
Name for the cftextinput control.
value
Optional
 
Initial value to display in text control.
required
Optional
No
  • Yes: the user must enter or change text
  • No
range
Optional
 
Minimum-maximum value range, delimited by a comma. Valid only for numeric data.
validate
Optional
 
  • date: verifies format mm/dd/yy.
  • eurodate: verifies date format dd/mm/yyyy.
  • time: verifies time format hh:mm:ss.
  • float: verifies floating point format.
  • integer: verifies integer format.
  • telephone: verifies telephone format ###-###-####. The separator can be a blank. Area code and exchange must begin with digit 1 - 9.
  • zipcode: verifies, in U.S. formats only, 5- or 9-digit format #####-####. The separator can be a blank.
  • creditcard: strips blanks and dashes; verifies number using mod10 algorithm.
  • social_security_number: verifies format ###-##-####. The separator can be a blank.
  • regular_expression: matches input against pattern attribute.
onValidate
Optional
 
Custom JavaScript function to validate user input. The form object, input object, and input object value are passed to routine, which should return True if validation succeeds, False otherwise. The validate attribute is ignored.
pattern
Required if validate = "regular_
expression"
 
JavaScript regular expression pattern to validate input. Omit leading and trailing slashes.
message
Optional
 
Message text to display if validation fails.
onError
Optional
 
Custom JavaScript function to execute if validation fails.
size
Optional
 
Number of characters displayed before horizontal scroll bar displays.
font
Optional
 
Font name for text.
fontSize
Optional
 
Font size for text.
italic
Optional
No
  • Yes: italics text
  • No: normal text
bold
Optional
No
  • Yes: bold text
  • No: medium text
height
Optional
40
Height of the control, in pixels.
width
Optional
200
Width of the control, in pixels.
vSpace
Optional
 
Vertical spacing of the control, in pixels.
hSpace
Optional
 
Horizontal spacing of the control, in pixels.
align
Optional
 
Alignment of text entry box with respect to adjacent HTML content:
  • top
  • left
  • bottom
  • baseline
  • texttop
  • absbottom
  • middle
  • absmiddle
  • right
bgColor
Optional
 
Background color of control. For a hex value, use the form: textColor = "##xxxxxx", where x = 0-9 or A-F; use two pound signs or none.
  • any color, in hex format
  • black
  • red
  • blue
  • magenta
  • cyan
  • orange
  • darkgray
  • pink
  • gray
  • white
  • lightgray
  • yellow
textColor
Optional
 
Text color for control.
Options: same as for bgcolor attribute.
maxLength
Optional
 
The maximum length of text entered.
notSupported
Optional
 
Text to display if a page that contains a Java applet-based cfform control is opened by a browser that does not support Java, or has Java support disabled. For example:
notSupported = "<b> Browser must support Java to view ColdFusion Java Applets</b>"
If no message is specified, this message displays:
<b>Browser must support Java to <br> view ColdFusion Java Applets!</b>

Usage

This tag requires the client to download a Java applet. Downloading an applet takes time; therefore, using this tag might be slightly slower than using an HTML form element or the cfinput tag to get the same information.

For this tag to work properly. the browser must be JavaScript-enabled.

If the following conditions are true, a user's selection from query data that populates this tag's options continues to display after the user submits the form:

For more information, see cfform.

If the cfform preserveData attribute is "yes", and the form posts back to the same page, the posted value (not the value of the value attribute) of the cftextinput control is used.

Example

<h3>cftextinput Example</h3>
cftextinput provides simple validation for text fields in cfform and 
control over font information displayed in cfform input boxes 
for text. For example, the field below must not be blank, and 
provides a client-side message upon erring.
<cfform action = "cftextinput.cfm" method = "post">
<cfif IsDefined("form.myInput")>
  <h3>You entered 
    <cfoutput>
      #form.myInput#</cfoutput> into the text box </h3>
</cfif>

<cftextinput name = "myInput" 
  font = "Courier" fontSize = 12
  value = "Look, this text is red!" 
  textColor = "FF0000" 
  message = "This field must not be blank" 
  required = "Yes">

<input type = "Submit" name = "" value = "submit">
</cfform>

Comments