View comments | RSS feed
Contents > Developing ColdFusion MX Applications > Building Dynamic Forms > Input validation with JavaScript PreviousNext

Input validation with JavaScript

In addition to native ColdFusion input validation using the validate attribute of the cfinput and cftextinput tags, the following tags support the onvalidate attribute, which lets you specify a JavaScript function to handle your cfform input validation:

ColdFusion passes the following arguments to the JavaScript function you specify in the onvalidate attribute:

For example, if you code the cfinput tag as the following:

<cfinput type="text"
   ...
<!--- Do not include () in JavaScript function name --->
   onvalidate="handleValidation"
   ...
>

You define the JavaScript function as the following:

<script>
<!--
function handleValidation(form_object, input_object, object_value) {
...
}
//-->
</script>

Contents > Developing ColdFusion MX Applications > Building Dynamic Forms > Input validation with JavaScript PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


halL said on Jan 20, 2004 at 8:57 AM :
This page might be made clearer by indicating tht the form and input objects passed to the function are the JavaScript DOM objects for the form (cfform) and the input tag, respectively.
profit11 said on Feb 25, 2004 at 2:37 PM :
halL is right. And an example would be even better.
No screen name said on Aug 25, 2004 at 11:56 PM :
No idea of how to use this function for validation of cfgrid columns...
not able to get any help from macromedia site or from coldfusion docs!!
Lord Bron said on Jul 6, 2005 at 11:19 AM :
Here's an example that I made. You can use it to check other objects in the form as well, not just the object calling the function.

My script below is on a non-required cfinput tag to properly validate a cfselect object, since the "required" attribute for cfselect doesn't work so hot.

This script makes sure the Option selected is not the "Please Choose a State..." option.

********************************

<script language="javascript1.4" type="text/javascript">
function checkStateSelect(form_object, input_object, object_value)
{
if (form_object.StateAbr.selectedIndex == 0)
{
return false;
}
else
{
return true;
}
}
</script>

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/dynami45.htm