Question

From a best-practice or performance standpoint which option is best to use for testing if a FORM value is not blank?

<cfif NOT isNull(FORM.Forename)>

OR

<cfif Len(Trim(FORM.Forename)) GT 0>

OR

<cfif FORM.Forename NEQ "">

I don't want the value to be valid if it has something silly like 4 blank spaces in it. I guess 4 blank spaces is not technically a NULL value?

Was it helpful?

Solution

The second

<cfif Len(Trim(FORM.Forename)) GT 0>

The first will not be null. Cf will receive an empty string or no form element. The third is covered by the second.

You may need to wrap the form element with an isdefined depending on the form element type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top