<cfinput>

Used inside <cfform> to place radio buttons, checkboxes, or text boxes.

Provides input validation for the specified control type.

This tag cannot have a body.

This tag is also supported within <cfscript>

Requires Extension: Form Tags

<cfinput autosuggest=string autosuggestbinddelay=number autosuggestminlength=number delimiter=string maxresultsdisplayed=number onbinderror=string showautosuggestloadingicon=boolean sourcefortooltip=string typeahead=boolean validateat=string type=string name=string value=string required=boolean range=string validate=string bind=string bindattribute=string bindonload=boolean border=string accept=string accesskey=string align=string alt=string checked=string daynames=string firstdayofweek=number monthnames=string height=string width=string hspace=string label=string mask=string notab=string datafld=string datasrc=string dataformatas=string disabled=string ismap=string readonly=string src=string usemap=string title=string dir=string lang=string onvalidate=string pattern=string message=string onerror=string size=string maxlength=number passthrough=any class=string id=string onblur=string onchange=string onclick=string ondblclick=string onfocus=string onkeydown=string onkeypress=string onkeyup=string onmousedown=string onmousemove=string onselect=string onmouseup=string onmouseout=string onmouseover=string style=string tabindex=string enabled=string visible=string tooltip=string autocomplete=string autofocus=string form=string formaction=string formenctype=string formmethod=string formnovalidate=string formtarget=string list=string max=string min=string multiple=string placeholder=string step=string >
Attribute Description
autosuggest
string, optional

Specifies entry completion suggestions to display as the user types into a text input. The user can select a suggestion to complete the text entry.

The valid value can be either of the following:

  • A string consisting of the suggestion values separated by the delimiter specified by the delimiter attribute.
  • A bind expression that gets the suggestion values based on the current input text. Valid only for cfinput type="text".
autosuggestbinddelay
number, optional

The minimum time between autosuggest bind expression invocations, in seconds. Use this attribute to limit the number of requests that are sent to the server when a user types. Valid only for cfinput type="text"

autosuggestminlength
number, optional

The minimum number of characters required in the text box before invoking a bind expression to return items for suggestion.

Valid only for cfinput type="text".

delimiter
string, optional

The delimiter to use to separate entries in a static autosuggest list. This attribute is meaningful only if the autosuggest attribute is a string of delimited values.

maxresultsdisplayed
number, optional

The maximum number suggestions to display in the autosuggest list. Valid only for cfinput type="text".

onbinderror
string, optional

The name of a JavaScript function to execute if evaluating a bind expression, including an autosuggest bind expression, results in an error. The function must take two attributes: an HTTP status code and a message.

showautosuggestloadingicon
boolean, optional

A Boolean value that specifies whether to display an animated icon when loading an autosuggest value for a text input.

sourcefortooltip
string, optional

The URL of a page to display as a tool tip. The page can include HTML markup to control the format, and the tip can include images. If you specify this attribute, an animated icon appears with the text "Loading..." while the tip is being loaded.

typeahead
boolean, optional

A Boolean value that specifies whether the autosuggest feature should automatically complete a user's entry with the first result in the suggestion list.

Valid only for cfinput type="text".

validateat
string, optional

How to do the validation; one or more of the following: onSubmit, onServer or onBlur. onBlur and onSubmit are identical in Flash forms. For multiple values, use a comma-delimited list. Default: onSubmit

type
string, optional

The input control type to create:

  • button: push button.
  • checkbox: check box.
  • file: file selector; not supported in Flash.
  • hidden: invisible control.
  • image: clickable button with an image.
  • password: password entry control; hides input values.
  • radio: radio button.
  • reset: form reset button.
  • submit: form submission button.
  • text: text entry box.
  • datefield: Flash only; date entry field with an expanding calendar for selecting dates.
name
string, required

A name for the form input element.

value
string, optional

An initial value for the form input element.

required
boolean, optional

Enter Yes or No. Default is No.

range
string, optional

Enter a minimum and maximum value range, separated by a comma. Valid only for numeric data.

validate
string, 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. Number must have 13-16 digits.
  • social_security_number: verifies format ###-##-####. The separator can be a blank.
  • regular_expression: matches input against pattern attribute.
bind
string, optional

(not supported) A Flash bind expression that populates the field with information from other form fields.

bindattribute
string, optional

Specifies the HTML tag attribute whose value is set by the bind attribute. You can only specify attributes in the browser's HTML DOM tree, not Lucee-specific attributes. Ignored if there is no bind attribute. Valid only for cfinput type="text".

bindonload
boolean, optional

A Boolean value that specifies whether to execute the bind attribute expression when first loading the form. Ignored if there is no bind attribute. Valid only for cfinput type="text".

border
string, optional

passed through to input tag created, only used for type html.

accept
string, optional

passed through to input tag created, only used for type html.

accesskey
string, optional

passed through to input tag created, only used for type html.

align
string, optional

passed through to input tag created, only used for type html.

alt
string, optional

passed through to input tag created, only used for type html.

checked
string, optional

Selects a control. No value is required. Applies if type=radio or checkbox. Default: false

daynames
string, optional

A comma-delimited list that sets the names of the weekdays displayed in the calendar. Sunday is the first day and the rest of the weekday names follow in the normal order.

Default is: S,M,T,W,Th,F,S

firstdayofweek
number, optional

Integer in the range 0-6 specifying the first day of the week in the calendar, 0 indicates Sunday, 6 indicates Saturday. Default is: 0

monthnames
string, optional

A comma-delimited list of the month names that are displayed at the top of the calendar.

height
string, optional

Applies to most Flash types, HTML image type on some browsers. The height of the control, in pixels. The displayed height might be less than the specified size.

width
string, optional

Applies to most Flash types, HTML image type on some browsers. The width of the control, in pixels. For Flash forms, Lucee ignores this attribute if you also specify a size attribute value.

hspace
string, optional

passed through to form tag created, only used for type html.

label
string, optional

Label to put next to the control on a Flash or XML form. Not used for button, hidden, image, reset, or submit types.

mask
string, optional

A mask pattern that controls the character pattern that users can enter, or that the form sends to Lucee.

In HTML and Flash for type=text use:

  • A = [A-Za-z]
  • X = [A-Za-z0-9]
  • 9 = [0-9]
  • ? = Any character
  • all other = the literal character

In Flash for type=datefield use:

  • D = day; can use 0-2 mask characters.
  • M = month; can use 0-4 mask characters.
  • Y = year; can use 0, 2, or 4 characters.
  • E = day in week; can use 0-4 characters.
notab
string, optional

passed through to form tag created, only used for type html.

datafld
string, optional

passed through to form tag created, only used for type html.

datasrc
string, optional

passed through to form tag created, only used for type html.

dataformatas
string, optional

passed through to form tag created, only used for type html.

disabled
string, optional

Disables user input, making the control read-only. To disable input, specify disabled without an attribute or disabled="true". To enable input, omit the attribute or specify disabled="false".

ismap
string, optional

passed through to form tag created, only used for type html.

readonly
string, optional

passed through to form tag created, only used for type html.

src
string, optional

Applies to Flash button, reset, submit, and image types, and the HTML image type. URL of an image to use on the button. Flash does not support GIF images.

usemap
string, optional

passed through to form tag created, only used for type html.

title
string, optional

passed through to form tag created, only used for type html.

dir
string, optional

passed through to form tag created, only used for type html.

lang
string, optional

passed through to form tag created, only used for type html.

onvalidate
string, optional

The name of a JavaScript function used to validate user input. The form object, input object, and input object value are passed to the specified routine, which should return true if validation succeeds and false otherwise. If used, the validate attribute is ignored.

pattern
string, optional

The JavaScript regular expression pattern to use to validate the input. Required only if you specify validate = "regular_expression".

message
string, optional

Message text to appear if validation fails.

onerror
string, optional

The name of a JavaScript function you want to execute in the event of a failed validation.

size
string, optional

The size of the input control. Ignored if type is Radio or Checkbox.

maxlength
number, optional

The maximum length of text entered, if n type is Text.

passthrough
any, optional

HTML attributes that are not explicitly supported by cfinput. If you specify an attribute and value, they are passed to the HTML code generated for the cfinput tag.

class
string, optional

passed through to form tag created, only used for type html.

id
string, optional

passed through to form tag created, only used for type html.

onblur
string, optional

passed through to form tag created, only used for type html.

onchange
string, optional

passed through to form tag created, only used for type html.

onclick
string, optional

passed through to form tag created, only used for type html.

ondblclick
string, optional

passed through to form tag created, only used for type html.

onfocus
string, optional

passed through to form tag created, only used for type html.

onkeydown
string, optional

passed through to form tag created, only used for type html.

onkeypress
string, optional

passed through to form tag created, only used for type html.

onkeyup
string, optional

passed through to form tag created, only used for type html.

onmousedown
string, optional

passed through to form tag created, only used for type html.

onmousemove
string, optional

passed through to form tag created, only used for type html.

onselect
string, optional

passed through to form tag created, only used for type html.

onmouseup
string, optional

passed through to form tag created, only used for type html.

onmouseout
string, optional

passed through to form tag created, only used for type html.

onmouseover
string, optional

passed through to form tag created, only used for type html.

style
string, optional

passed through to form tag created, only used for type html.

tabindex
string, optional

passed through to form tag created, only used for type html.

autocomplete
string, optional

HTML attribute: Specifies the types of files that can be submitted through a file upload (only for type="file")

autofocus
string, optional

Specifies that the input field should have focus on page load (not for type="hidden")

form
string, optional

HTML attribute: Specifies one or more forms the input field belongs to

formaction
string, optional

HTML attribute: Overrides the form's action attribute. Must be a valid URL that defines where to send the data when the form is submitted (for type="submit" and type="image")

formenctype
string, optional

HTML attribute: Overrides the form's enctype attribute. Specifies how form-data should be encoded before sending it to the server (for type="submit" and type="image")

formmethod
string, optional

HTML attribute: Overrides the form's method attribute. Defines the HTTP method for sending data to the action URL (for type="submit" and type="image")

formnovalidate
string, optional

HTML attribute: Overrides the form's novalidate attribute. If present the input field should not be validated when submitted

formtarget
string, optional

HTML attribute: Overrides the form's target attribute. Specifies the target window used when the form is submitted (for type="submit" and type="image")

list
string, optional

HTML attribute: Refers to a datalist containing predefined options for the input field

max
string, optional

HTML attribute: Specifies the input field's maximum value. Use together with the "min" attribute to create a range of legal values

min
string, optional

HTML attribute: Specifies the input field's minimum value. Use together with the "max" attribute to create a range of legal values

multiple
string, optional

HTML attribute: If present the user is allowed more than one value

placeholder
string, optional

HTML attribute: Specifies a hint to help users fill out the input field

step
string, optional

HTML attribute: Specifies the legal number intervals for the input field

Unimplemented Attribute(s)

Attribute Description
enabled
string, optional

Flash only: Boolean value specifying whether the control is enabled. A disabled control appears in light gray. The inverse of the disabled attribute. Flash only. Default: true

* unimplemented *
visible
string, optional

Flash only: Boolean value specifying whether to show the control. Space that would be occupied by an invisible control is blank. Default: true

* unimplemented *
tooltip
string, optional

Flash only: Text to display when the mouse pointer hovers over the control.

* unimplemented *

Examples

<cfform name="sampleForm">
    <label>FirstName:</label>
    <cfinput type ="Text" name ="firstname" 
    message ="Enter firstname" 
    required ="yes">
    <br/><br/>
<span class="nt">&lt;label&gt;</span>Password:<span class="nt">&lt;/label&gt;</span>
<span class="nt">&lt;cfinput</span> <span class="na">type =</span><span class="s">&quot;password&quot;</span> <span class="na">name =</span><span class="s">&quot;password&quot;</span> 
<span class="na">message =</span><span class="s">&quot;Enter password&quot;</span> 
<span class="na">required =</span><span class="s">&quot;yes&quot;</span><span class="nt">&gt;</span>

</cfform>

See also