Just a suggestion, but it already exsists... almost!
If you look at the docs for CFInput you will see OnError="" and
OnValidate="" as optional fields. I just had to use these to modify the
"Phone Number" validation of a CFInput box.
Here's the scoop: When you use a CFInput it's doing Javascript, right?
Well, they made this nifty little thing so that you can make it a little
smarter. Here's an example (yes, I actually ran it to make sure it works:
<script>
function ExtraCheck(cForm, cObject, cValue) {
if (cValue.length < 10)
return false;
else
return true;
}
function MoveFocus(cForm, cObject, cValue, cErrorText) {
alert(cErrorText);
cObject.focus();
return false;
}
</script>
<cfform name="testing" method="post" action="test.cfm">
Name: <cfinput type="Text"
name="Name"
message="Please enter your name"
required="Yes"
onError="MoveFocus"><br>
Phone Number: <cfinput type="Text"
name="PhoneNumber"
message="Please enter your phone number"
required="Yes" onValidate="ExtraCheck" onError="MoveFocus"
maxlength="30"><br>
Note: <cfinput type="Text"
name="Extra"
message="Please enter something else, at least 10 characters long"
required="Yes"
onValidate="ExtraCheck"
onError="MoveFocus"
maxlength="30"><br>
<input type="submit" name="Process">
</cfform>
<cfif IsDefined("Form.Process")>
<cfoutput><hr>
#Form.Name#<br>
#Form.PhoneNumber#<br>
#Form.Extra#
</cfoutput>
</cfif>
Hatton
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 10:56 AM
To: CF-Talk
Subject: if anyone from macromedia is listening - cfinput request
please make it so cfinput can do a focus() method for the field that is
causing the exception. this is the only thing that prevents me from using
the tag and having to do it in javascript.
Anthony Petruzzi
Webmaster
954-321-4703
http://www.sheriff.org
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists