简体   繁体   English

为什么当我在网站上上传时我的 jQuery 不起作用

[英]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.

相关问题 当我将其导入Wordpress网站时,为什么我的JQuery / CSS代码不起作用? - Why isn't my JQuery/CSS code working when I import it into my Wordpress website? 为什么我的悬停添加类在Jsfiddle上有效,但在我的网站上却不可用? 我的标题中是否缺少某些内容? - Why is my add class on hover working on Jsfiddle but not on my website? Am I missing something in my header? 为什么jquery新闻自动收报机无法在我的网站上运行? - Why the jquery news ticker is not working on my website? 为什么打开浏览器时jQuery无法正常工作/无法显示? - Why is my jQuery not working/showing when I open my browser? 当我尝试在我的网站上构建键盘快捷键时,为什么jQuery keyup无效? - Why jQuery keyup is not working while I try to build keyboard shortcut on my website? 为什么我的网站脚本出现此错误? - Why I am getting this error with the script in my website? 当我在脚本中使用AJAX时,JQuery停止工作。 我究竟做错了什么? - JQuery stops working when I use AJAX in my script. What am I doing wrong? 为什么我的网站子网址在提交表单时不起作用,但在我手动输入时起作用 - Why doesnt my website sub url working when submitting form but works when i manually enter it 为什么在我使用JQuery的$ .parseHTML时缺少HTML块的外部div? - Why am I missing the outer div of my HTML block when I use JQuery's $.parseHTML? 单击复选框后,我的复选框更改事件不起作用。 我正在使用bootstrap和jquery - My checkbox change event is not working when clicked. I am using bootstrap and jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM