Cheers for that, Im now trying to convert it to script. I hav got the Luhm
MOD 10 algorithm working fine.
I am having difficulty in getting the first part of the script to work. I
pass the card type to the switch and then depending which card is passed,
it carries out a regular expression check on the card number passed into
the function. These reg exressions work fine using regular <cfml> tags.
but the switch always reverts to the default case. Can you see any
mistakes?
Here is my code
<cfinvoke method="checklength" returnvariable="valid">
<cfinvokeargument name="card_number" value="#form.cardnumber#">
<cfinvokeargument name="cardtype" value="#form.cardtype#">
</cfinvoke>
<cfscript>
function Checklength(cardtype,card_number) {
var valid = 'true';
var card = 'cardtype';
var cardnumber = card_number;
/** First, pass card type to switch*/
switch(card){
/** if visa, check 16 chars in length and that it starts with a 4*/
case 'visa':
if (NOT refindnocase("^[4]{1}[0-9]{15}$",cardnumber)){
valid = 'false';
}
else
{
valid = 'true';
}
break;
/** if mastercard, check 16 chars in length and that it starts with 51
-
55*/
case 'mcard':
if (NOT refindnocase("^[51-55]{2}[0-9]{14}$",cardnumber)){
valid = 'false';
}
else
{
valid = 'true';
}
break;
default:
valid = 'tryagain';
}
return valid;
}
</cfscript>
<cfoutput>#valid#</cfoutput>
Once i have finished the script i will post on here for all to use.
Jamie
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004