Display an alert box.

Display an alert box.

This will display an alert box if the validation fails. In this example, the field must contain a value.

Some words about the cfinput tag:
Name:        Required. A name for the form input element.
Value:        Optional. An initial value for the form input element.
Size:           Optional. The size of the input control. Ignored if type is Radio or Checkbox.
Maxlength: Optional. The maximum length of text entered, if n type is Text.
Required:   Optional. Enter Yes or No. Default is No.
Message:   Optional. Message text to appear if validation fails.

Click here for more information about the cfinput tag.

If you look at the "View Source" in the browser, you see that Coldfusion have added the necessary JavaScript code.

<!-- cfform post it contains to the same page, test.cfm -->

<cfform action = "test.cfm" method= "post">

<!--- E-mail address: --->

<cfinput name= "mail_address" type= "text" value= "" size= "20" maxlength= "20" required= "yes" message= "E-mail address is required.">

<div align="center">

<input name= "e_mail" type= "submit" value= "Submit">

</div>

</cfform>

Advertisement

No User Comments.

No User Comments, be the first one to write your comments?

ApplayIT is owned by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.