Skip to main content

Posts

Showing posts from April, 2014

javascript function kiểm tra mã thẻ tín dụng hợp lệ - validate a valid credit card number

function IsValidCreditCard(ccNumb) {     ccNumb = ccNumb.ReplaceAll('-', ''); // strip hyphen     ccNumb = ccNumb.ReplaceAll(' ', '');     var valid = "0123456789";   // Valid digits in a credit card number     var len = ccNumb.length;  // The length of the submitted cc number     var iCCN = parseInt(ccNumb);  // integer of ccNumb     var sCCN = ccNumb.toString();  // string of ccNumb     sCCN = sCCN.replace(/^\s+|\s+$/g, '');  // strip spaces     var iTotal = 0;  // integer total set at zero     var bNum = true;  // by default assume it is a number     var bResult = false;  // by default assume it is NOT a valid cc     var temp;  // temp variable for parsing string     var calc;  // used for calculation of each digit     // Determine if the ccNumb is in fact all numbers   ...