jQuery validate creditcard2, how to only validate the credit card if the card is required?

那年仲夏 提交于 2019-12-24 23:05:04

问题


In my validation rules, I have the following code:

CardNumber:{
        required:function(element){ return validateIfDeposit();},
        creditcard2: function(){ return $('#CardType').val(); }
    },

The required function works great (I use it successfully for the nameOnCard field). Unfortunately the CardNumber field is still coming back invalid. How can I have the credit card field be valid if the field is not required?

来源:https://stackoverflow.com/questions/9068588/jquery-validate-creditcard2-how-to-only-validate-the-credit-card-if-the-card-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!