这是我的javascript代码:
<script>
$(function() {
$('#input').validateCreditCard(function(result) {
$('.log').html('Card type: ' + (result.card_type == null ? '-' : result.card_type.name)
+ '<br>Valid: ' + result.valid
+ '<br>Length valid: ' + result.length_valid
+ '<br>Luhn valid: ' + result.luhn_valid);
});
});
</script>
我将结果值打印在html标签中,如:
<h1><script>document.write(result.card_type.name())</script></h1>
<h1><script>document.write(result.valid())</script></h1>
<h1><script>document.write(result.length_valid())</script></h1>
<h1><script>document.write(result.luhn_valid())</script></h1>
bt它没有显示出价值。。!!
"result"变量是该函数的局部变量。你不能那样在文档中使用它。
删除HTML中的这4行,只需添加以下内容:
<h1 class="log"></h1>
你得到想要的结果了吗?如果没有,您需要更好地解释什么是"validateCreditCard"。