isBit(x)
Last updated February 14, 2006
Version: 1 | Requires: CF5 | Library: DataManipulationLib
Description:
isBit checks to see if a value is 1 or 0. This comes in handy when checking radio button values where you have two radio buttons with bit values. While this does not save a lot of typing, it does help, especially when your form has an abundance of radio buttons, etc.
Return Values:
Returns a boolean.
Example:
<cfset var1 = 1 />
<cfset var2 = "1" />
<cfset var3 = "test string" />
<cfset var4 = "-0" />
<cfset var5 = 000 />
<cfset var6 = arrayNew(1) />
<cfset var7 = 0 />
<cfoutput>
#isBit(var1)# - true<br />
#isBit(var2)# - true<br />
#isBit(var3)# - false<br />
#isBit(var4)# - false<br />
#isBit(var5)# - false<br />
#isBit(var6)# - false<br />
#isBit(var7)# - true<br />
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
x | Value to check. | Yes |
Full UDF Source:
/**
* Checks that a value is equal to 1 or 0.
*
* @param x Value to check. (Required)
* @return Returns a boolean.
* @author Mike Tangorre (mtangorre@cfcoder.com)
* @version 1, February 14, 2006
*/
function isBit(x){
if(isSimpleValue(x) and len(x) eq 1 and (x eq 0 or x eq 1))
return true;
else
return false;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016