Used inside cfform to place radio buttons, checkboxes, or text boxes. Provides input validation for the specified control type.
<cfinput type = "input_type" name = "name" value = "initial_value" required = "Yes" or "No" range = "min_value, max_value" validate = "data_type" onValidate = "javascript_function" pattern = "regexp" message = "validation_msg" onError = "text" size = "integer" maxLength = "integer" checked passThrough = "HTML_attributes">
cfapplet, cfform, cfgrid, cfselect, cfslider, cftextinput, cftree
You can add standard and dynamic HTML form tag attributes and values to the cfinput tag by using the passThrough attribute. They are passed through ColdFusion to the browser in creating a form.
If you specify a value in quotation marks, you must escape the quotation marks by doubling them, for example,
passThrough = "readonly = " "YES " " "
cfinput supports the JavaScript onClick event in the same manner as the HTML input tag:
<cfinput type = "radio"
name = "radio1" onClick = "JavaScript_function">
|
Note
|
<!--- This example shows the use of cfinput to validate input --->
<html>
<head>
<title>
cfinput Example
</title>
</head>
<body bgcolor = silver>
<H3>cfinput Example</H3>
<!--- this example shows the use of cfinput within a cfform to
ensure simple validation of text items --->
<cfform action = "cfinput.cfm" method = "POST" enableCAB = "Yes">
<!--- phone number validation --->
Phone Number Validation (enter a properly formatted phone number):
<BR><cfinput type = "Text" name = "MyPhone" message = "Please enter telephone
number, formatted xxx-xxx-xxxx (e.g. 617-761-2000)"
validate = "telephone"
required = "Yes"><font size = -1 color = red>Required</font>
<!--- zip code validation --->
<P>Zip Code Validation (enter a properly formatted zip code):
<BR><cfinput type = "Text" name = "MyZip" message = "Please enter zip code,
formatted xxxxx or xxxxx-xxxx" validate = "zipcode"
required = "Yes"><font
size = -1 color = red>Required</font>
<!--- range validation --->
<P>Range Validation (enter an integer from 1 to 5):
<BR><cfinput type = "Text" name = "MyRange" range = "1,5"
message = "You must enter an integer from 1 to 5"
validate = "integer" required = "No">
<!--- date validation --->
<P>Date Validation (enter a properly formatted date):
<BR><cfinput type = "Text" name = "MyDate" message = "Please enter
a correctly formatted date (dd/mm/yy)" validate = "date"
required = "No">
<input type = "Submit" name = "" value = "send my information">
</cfform>
</body>
</html>
LiveDocs comments are not longer enabled for ColdFusion 5.0. Please use one of the following resources instead.
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 5.0