I use this one sometimes if I have a query that creates the form elements for
me:
<cfset validate_list = query.fieldnames>
<cfset req ='<span class="req">*</span>'>
<cfsavecontent variable="jsstring">
<cfloop list="#validate_list#" delimiters="," index="ee">
<!--- cheesy grammar helper --->
<cfif left(ee, 1) contains "a"
or left(ee, 1) contains "e"
or left(ee, 1) contains "i"
or left(ee, 1) contains "o"
or left(ee, 1) contains "u">
<cfset verb = "an">
<cfelse>
<cfset verb = "an">
</cfif>
<cfset srtng = replace(ee,"_"," ","all")>
<cfoutput>
if(document.form.#ee#.value.length == 0)
{
errors = errors + 1;showall =
showall + "You must provide #verb# #srtng#.\n";
}
</cfoutput>
</cfloop>
</cfsavecontent>
<script language="javascript" type="text/javascript">
function checkform()
{
errors = 0;
showall = '';
<cfoutput>#jsstring#</cfoutput>
if(errors == 0)
{
document.form.submit();
}
else
{
alert(showall);
}
}
</script>
<style>
..req{
color:red;
}
</style>
Then create your form with the query. I also have a form validation with
different data types and a custom attribute called regex. If it contains a
regex value, it uses the regex to validate the field:
<input name="email" regex="email"> #req#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316837
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4