Xbasic

CCVALID Function

Syntax

Validation_Flag as L = CCVALID(C credit_card_number[,N option])

Arguments

credit_card_number

A string of numbers in character format.

option

Optional. A number that indicates the type of checksum to calculate. 0 = Credit Card (Default), 1 = PostNet, 2 = UPC

Description

Returns TRUE if a field contains a valid credit card number.

Discussion

CCVALID() returns .T. (TRUE) if a field contains a valid Credit_Card_Number ; otherwise, it returns .F. (FALSE). Only digits, dashes ("-"), and blanks spaces are allowed in the Credit_Card_Number. Alpha Anywhere automatically strips out blank spaces and dashes in the Credit_Card_Number before checking its validity. A common requirement in invoicing applications is to catch data entry errors in credit card numbers. For example, to prevent the entry of invalid card numbers into a field called CARDNO, create a validation rule for the card number field with the expression CCVALID(CARDNO). The CCVALID() function works as follows: the last digit of the card number (the checksum digit) is ignored. For the remaining numbers, Alpha Anywhere computes a checksum (see the CHKDIGIT()function). If the checksum equals the checksum digit, the card number is valid.

Example

ccvalid(CARDNO) -> TRUE, if CARDNO contains a valid credit card number

See Also