How to check if is function on jquery, but function is in another .js file?
validation.js:
if ($.isFunction('payment')) {
$('[data-numeric]').payment('restrictNumeric');
$('.cc-number').payment('formatCardNumber');
$('.cc-exp').payment('formatCardExpiry');
$('.cc-cvc').payment('formatCardCVC');
}
this is false because func payments is in the payments.js .
Try like this
if (typeof payment === "function")
{
// Do something
}
problem is solved. its works:
if ($.fn.payment) {
//do something
}
Try to check like as follows,
if (typeof payment !== 'undefined' && $.isFunction(payment)) {
$('[data-numeric]').payment('restrictNumeric');
$('.cc-number').payment('formatCardNumber');
$('.cc-exp').payment('formatCardExpiry');
$('.cc-cvc').payment('formatCardCVC');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With