Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trycf/50969bc01cae75a8e10471eddb3db339 to your computer and use it in GitHub Desktop.

Select an option

Save trycf/50969bc01cae75a8e10471eddb3db339 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
public boolean function isNumber(any val) {
if (!isNumeric(arguments.val)) return false;
if (find(" ", arguments.val) return false;
// 0001890 is not strict numeric -> serialize as string
if (arguments.val >= 1 && left(arguments.val, 1) == "0") return false;
// .111111 is not strict numeric -> serialize as string
if (left(arguments.val, 1) == ".") return false;
// 111111. is not strict numeric -> serialize as string
if (right(arguments.val, 1) == ".") return false;
// +111111 is not strict numeric -> serialize as string
if (left(arguments.val, 1) == "+") return false;
// mehrere "." auschließen
if (listLen(arguments.val, ".") > 2) return false;
return true;
}
writedump(isNumber(" 02266"))
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment