function ccValid(val) {
	var cardNum = val;
	var len = cardNum.length;
	var checksum = 0;    
	if (len < 2)  {
		return false;
	}
	for (var i = 1; i < len; i++) {
		var ch = cardNum.charAt(len - 1 - i);
		var digit = parseInt(ch);
		var temp = digit * (1 + (i % 2));
		if (temp < 10)
			checksum = checksum + temp;
		else
			checksum = checksum + temp - 9;
	}
	checksum = (10 - (checksum % 10)) % 10;
	if (parseInt(cardNum.charAt(len - 1)) != checksum)
		return false;
	return true;
}
