﻿function trim(a) { return a.replace(/^\s+|\s+$/g, "") } function checkCC(a) { String.prototype.startsWith = function (a) { return this.match("^" + a) == a }; Array.prototype.has = function (a, b) { for (var c = 0; c < this.length; c++) { if (this[c] == a) return !b ? true : c } return false }; a = a.replace(/[^0-9]/g, ""); var b = new Array; var c = 0; var d = 0; var e = a; while (e != 0) { b[c] = e % 10; e -= b[c]; e /= 10; c++; d++ } var f = -1; if (a.startsWith("5")) { f = 1 } else if (a.startsWith("4")) { f = 2 } else if (a.startsWith("34") || a.startsWith("37")) { f = 3 } else { f = -1 } return f } function SelectCardType() { var a = jQuery("input[name$='CardNumber'][type='text']"); var b = a.attr("value"); var c = checkCC(b); if (c == "-1") { jQuery("#imgMasterCard").attr("src", "/images/mastercard_disabled.png"); jQuery("#imgVisa").attr("src", "/images/visa_disabled.png"); jQuery("#imgAmex").attr("src", "/images/amex_disabled.png") } else if (c == "1") { jQuery("#imgMasterCard").attr("src", "/images/mastercard.png"); jQuery("#imgVisa").attr("src", "/images/visa_disabled.png"); jQuery("#imgAmex").attr("src", "/images/amex_disabled.png") } else if (c == "2") { jQuery("#imgMasterCard").attr("src", "/images/mastercard_disabled.png"); jQuery("#imgVisa").attr("src", "/images/visa.png"); jQuery("#imgAmex").attr("src", "/images/amex_disabled.png") } else if (c == "3") { jQuery("#imgMasterCard").attr("src", "/images/mastercard_disabled.png"); jQuery("#imgVisa").attr("src", "/images/visa_disabled.png"); jQuery("#imgAmex").attr("src", "/images/amex.png") } else { jQuery("#imgMasterCard").attr("src", "/images/mastercard.png"); jQuery("#imgVisa").attr("src", "/images/visa.png"); jQuery("#imgAmex").attr("src", "/images/amex.png") } }
