[英]why my jQuery is not working when i am uploading on the website
When I write the code on console, its working.当我在控制台上编写代码时,它可以正常工作。 When I upload on the website it is not working.
当我在网站上上传时,它不起作用。
I want to do a stripe card details fields validation.我想做一个条纹卡详细信息字段验证。 When the details are filled and while filling the border color of the box should be green same as card details
填写详细信息时,填充框的边框颜色应与卡片详细信息相同
Code that I tried:我试过的代码:
if (jQuery('.input-text.wc-credit-card-form-card-expiry').val() == '') {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'red');
}
else {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'green');
}
Webpage URL: https://www.preprod.swett.se/checkout-2/网页网址: https : //www.preprod.swett.se/checkout-2/
If you check on the website.如果您在网站上查看。 Card number field is working correct.
卡号字段工作正常。 I want the expiration date and cvv field date should also work same as card details
我希望到期日期和 cvv 字段日期也应该与卡片详细信息相同
Could you please help me with this jQuery.你能帮我这个jQuery吗?
Try this and see if it works, please make sure to include jQuery
:试试这个,看看它是否有效,请确保包含
jQuery
:
jQuery('#stripe-card-expiry').on('keyup', function(){
var $input = jQuery(this);
$input.css('border-color', !$input.val() ? 'red' : 'green');
});
Card number field is working correct because of this code由于此代码,卡号字段工作正常
jQuery('#stripe-card-number').on('keyup', function ($) {
if (jQuery(this).val().length > 0) {
jQuery('#stripe-card-number').css('border', '2px solid #69bf29');
}
});
So, similaraly you need to trigger your code on keyup event for expiration date and cvv因此,类似地,您需要在 keyup 事件上触发代码以获取到期日期和 cvv
jQuery('.wc-credit-card-form-card-expiry').on('keyup', function ($) {
if (jQuery('.input-text.wc-credit-card-form-card-expiry').val() == '') {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'red');
}
else {
jQuery('.input-text.wc-credit-card-form-card-expiry').css('border-color', 'green');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.