I need to validate X number of fields. Each field is named “testFieldX”, where X is any real number greater that 1.
So basically what I have in a form are fields with names:
testField1
testField2
testField3
etc.
I need to iterate over all of them and validate.
Let’s assume I have 5 fields.
Then
<cfloop index="i" from="1" to="5">
<cfif form.testField & i EQ "">
Show error
</cfif>
</cfloop>
However it does not work. I get an error that the field name “testField” does not exists, which is true (only testField1+) exist. It seems like the things are not concatenating. Does it work only with strings?
How can I solve this problem?
The syntax you’re after is:
That will concatenate the strings as you’re expecting.