'); }); $("#pdp-slide1").replaceWith(pdpSlide1); $("#pdp-slide2").replaceWith(pdpSlide2); renderSlider(pdpSlide1, pdpSlide2); bLazy.revalidate(); var y = 0; $('img[name="imgProductx"]').each(function() { var imgUrl = $(this).attr('data-src'); //console.log(imgUrl); $('img#imgProductx' + y).attr('src', imgUrl).load(function() { }).error(function() { $(this).attr('src', ctx + '/assets/desktop/img/alfacart_default.png'); }); y++; }); } } }); }); $("#customBuyPDP").owlCarousel({ items : 3, lazyLoad : true, loop : false, nav : true, margin : 14, slideBy: 3, dots : false, navText : [ '', '' ] }); $('#command').validate({ errorClass: 'error_validate', focusInvalid: false, ignore: "", rules: { listName: { required: function(){ return $("#option1:checked").val() == 'new'; }, minlength: 2, maxlength: 25 }, listId: { required: function(){ return $("#option2:checked").val() == 'select'; } } }, highlight: function(element) { $(element).parent('div').addClass('has-error'); }, unhighlight: function(element) { $(element).parent('div').removeClass('has-error'); } }); $("#listName").on('input', function(){ var lengthName = $(this).val().length; var listName = $(this).val(); var urlCheckShoppinglist = "https://www.alfacart.com/checkShoppingList"; if(lengthName > 2){ $.ajax({ type : 'POST', url : urlCheckShoppinglist, data : 'listName='+listName, cache: 'false', success: function(data){ //console.log(data) if(data == true){ $("#alert_listName").show(); $("#btnAddShoppingList").prop('disabled',true); }else{ $("#alert_listName").hide(); $("#btnAddShoppingList").prop('disabled',false); statusName = true; } } }); } }); jQuery.validator.addMethod("emailvalid", function(sEmail) { var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; return filter.test(sEmail); }, "Please enter a valid email address."); $('#formReminder').validate({ errorClass: 'error_validate', focusInvalid: false, ignore: "", rules: { email: { required: true, email: true, emailvalid: true } }, highlight: function(element) { $(element).parent('div').addClass('has-error'); }, unhighlight: function(element) { $(element).parent('div').removeClass('has-error'); }, submitHandler : function(){ var memId = $("#memId").val(); var productid = $("#prodId").val(); var email = $("#inputEmail").val(); $.ajax({ type : 'POST', url : ctx + "/insertReminderProduct", data : 'productid='+productid+'&email='+email+'&memid='+memId, cache: 'false', beforeSend: function(){ $("#waitInsert").show(); }, success: function(data){ if(data == true) $("#waitInsert").html(' Sukses! Data berhasil dikirim'); else $("#waitInsert").html(' Data gagal kami kirim, silahkan coba kembali!'); } }); } }); $("#btnReminder").click(function(){ var validator = $('#formReminder').validate(); validator.resetForm(); var isLogin = $("#isLogin").val(); var isEmail = $("#isEmail").val(); if(isLogin == "false"){ $("#inputEmail").val(""); }else{ $("#inputEmail").val(isEmail); } $("#waitInsert").hide(); }); $("#qtyproduct").on("blur", function(){ var qty = $("#qtyproduct").val(); var qtyMin = $("#qtyMinSale").val(); var qtyMax = $("#qtyMaxSale").val(); var qtyIncrement = $("#qtyIncrement").val(); if((parseInt(qty) % parseInt(qtyIncrement)) != 0){ $("#infoMessage").html("Kuantitas yang dimasukkan harus kelipatan " + qtyIncrement); $("#infoProduct").modal("show"); $("#qtyproduct").val(qtyMin); } if(parseInt(qty) < parseInt(qtyMin)){ $("#infoMessage").html("Minimal kuantitas " + qtyMin); $("#infoProduct").modal("show"); $("#qtyproduct").val(qtyMin); } if(parseInt(qtyMax) > 0){ if(parseInt(qty) > parseInt(qtyMax)){ $("#infoMessage").html("Maksimal kuantitas " + qtyMax); $("#infoProduct").modal("show"); $("#qtyproduct").val(qtyMax); } } }); $("#btnAddtocart").click(function(){ var stock = $("#stockProduct").val(); var qty = $("#qtyproduct").val(); var productid = $("#prodId").val(); var pdpColor = $("#pdp-color").val(); var pdpSpek = $("#pdp-spek").val(); if(pdpColor == ''){ $("#errConfig").show(); $("#errConfig").html(' Silahkan pilih warna'); return false; }else if(pdpSpek == ''){ $("#errConfig").show(); $("#errConfig").html(' Silahkan pilih size'); return false; }else{ // if(parseInt(qty) > parseInt(stock)){ // $("#infoMessage").html("Ada stok kuantitas " + stock + ".