The other day I came up with this function:
<cfset not_required="billingform,address_2">
<cfloop collection="#form#" item="key">
<cfif not listFindNoCase(not_required,key) and trim(form[key]) is "">
<cfset variables.e = variables.e & "<li>#ucase(replace(key,'_',' ','all'))# is a required field.</li>">
</cfif>
</cfloop>
The only thing I am not happy about is it doesn't show the error messages in any kind of order, which makes longer form errors look kind of weird, but I don't consider that to be too big of an issue because most of the time a user is only gonna be shown 1 or 2 error messages.
So what do you think? How could this function be improved upon?
No comments