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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top