我试图弄清楚如何根据其数量来检测信用卡的类型.有谁知道一个明确,可靠的方法来找到这个?
如何在键入时格式化并验证每个4位数之间带有空格的信用卡号:
eg: 4464 6846 4354 3564
Run Code Online (Sandbox Code Playgroud)
我试过了:
$('.creditno').keyup(function() {
cc = $(this).val().split("-").join("");
cc = cc.match(new RegExp('.{1,4}$|.{1,4}', 'g')).join("-");
$(this).val(cc);
});
Run Code Online (Sandbox Code Playgroud)
请帮忙
嗨,我正在使用codeigniter.我想验证我的信用卡详细信息.我看到php中有类来验证信用卡号码.我在codeigniter看到了一个帮助器来验证信用卡
http://codeigniter.com/wiki/Credit_Card_Helper
/**
* Truncates a card number retaining only the first 4 and the last 4 digits. It then returns the truncated form.
*
* @param string The card number to truncate.
* @return string The truncated card number.
*/
function truncate_card($card_num) {
$padsize = (strlen($card_num) < 7 ? 0 : strlen($card_num) - 7);
return substr($card_num, 0, 4) . str_repeat('X', $padsize). substr($card_num, -3);
}
/**
* Validates a card expiry date. Finds the midnight on first day of the …
Run Code Online (Sandbox Code Playgroud)