我想从“输入”字段中打印出信用卡品牌,并且/或者如果可能的话,将其保存到PHP会话中。我应该在同一页上还是在下一页上做?
例如,用户在输入字段= "40"
中输入以VISA
开头的数字
是否可以使用if条件?
<span class="payment-errors required"></span> </div>
<script type="text/javascript">
var $cardinput = $('#checkout_card_number');
$('#checkout_card_number').validateCreditCard(function(result)
{
//console.log(result);
if (result.card_type != null)
{
switch (result.card_type.name)
{
case "visa":
$cardinput.css('background-position', '3px -34px');
$cardinput.addClass('card_visa');
break;
case "visa_electron":
$cardinput.css('background-position', '3px -72px');
$cardinput.addClass('card_visa_electron');
break;
case "mastercard":
$cardinput.css('background-position', '3px -110px');
$cardinput.addClass('card_mastercard');
break;
case "maestro":
$cardinput.css('background-position', '3px -148px');
$cardinput.addClass('card_maestro');
break;
case "discover":
$cardinput.css('background-position', '3px -186px');
$cardinput.addClass('card_discover');
break;
case "amex":
$cardinput.css('background-position', '3px -223px');
$cardinput.addClass('card_amex');
break;
default:
$cardinput.css('background-position', '3px 3px');
break;
}
} else {
$cardinput.css('background-position', '3px 3px');
}
}
</script>