IsISBN(isbn)
Last updated May 16, 2002
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Checks to to see if value is a valid ISBN.
Return Values:
Returns a boolean.
Example:
<cfoutput>
#isISBN("013152447X")#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
isbn | ISBN string to check. | Yes |
Full UDF Source:
/**
* Checks to to see if value is a valid ISBN.
*
* @param isbn ISBN string to check. (Required)
* @return Returns a boolean.
* @author Alex (axs@arbornet.org)
* @version 1, May 16, 2002
*/
function IsISBN(isbn) {
var total = 0;
var test = 0;
var check_digit = 0;
var i = 1;
if (len(isbn) neq 10) return false;
test = left(isbn,9);
check_digit = right(isbn,1);
if (NOT isnumeric(test)) return false;
for ( i = 1; i lt 10; i=i+1) {
total = total + (Mid(isbn, i, 1) * i);
}
test = total mod 11;
if (test eq 10) test = "X";
if (test eq check_digit) 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