JavaScript商城购物车结算/收货/小计和加减/表单验证
2017-06-14 15:30
351 查看
$(function() { $(".classactive li").click(function(){ $(this).find("label").addClass("active") $(this).siblings().find("label").removeClass("active") });//默认地址按钮样式 //切换菜单样式 $('#tabTitle a').on('click',function(){ $(this).addClass('active').siblings().removeClass('active'); $('.invoicetip').eq($(this).index()).addClass('active').siblings().removeClass('active'); }) $(".address_btn").click(function(){ $(".tip_Receiving").show(); }) $(".popup .colse").click(function(){ $(".tip_Receiving").hide(); }) $(".popup .btn_2").click(function(){ $(".tip_Receiving").hide(); })//收货信息弹窗 $(".invoice_btn").click(function(){ $(".invoice_tip").show(); }) $(".invoice .colse").click(function(){ $(".invoice_tip").hide(); }) $(".invoice .btn_2").click(function(){ $(".invoice_tip").hide(); }) //发票信息弹窗 //发票3 增值税发票 $(".VATinvoiceorder .btn_1").click(function(){ $(".section_two").show(); $(".section_one").hide(); $(".section_third").hide(); }) //发票3 增值税发票VATinvoiceorder $(".Newly_btn").click(function(){ $(".tip_Newly").show(); }) $(".tip_Newly .colse").click(function(){ $(".tip_Newly").hide(); }) $(".tip_Newly .btn_2").click(function(){ $(".tip_Newly").hide(); })//添加新地址 弹窗 $(".modify-btn").click(function(){ $(".Modify-address").show(); }) $(".Modify-address .colse").click(function(){ $(".Modify-address").hide(); }) $(".Modify-address .btn_2").click(function(){ $(".Modify-address").hide(); }) $(".link_purchase").click(function(){ $(".Platform").show(); }) $(".Platform .colse").click(function(){ $(".Platform").hide(); }) $(".Platform .btn_2").click(function(){ $(".Platform").hide(); }) //开发票 弹窗 //结算提交按钮弹窗 $(".footcashpurchase").click(function(){ $(".check_style_purchase input[type=checkbox]").each(function(){ if(this.checked){ $(".payment").show(); $(".footcashpurchase").removeClass('active'); $(".Tip_input").hide(); } else{ $(".payment").hide(); $(".Tip_input").show(); $(".footcashpurchase").addClass("active"); return false; } }); }); $(".payment .colse").click(function(){ $(".payment").hide(); }) //结算提交按钮弹窗结束 //人工汇款弹窗 $(".tip_active").click(function(){ $(".Manual").show(); $(".payment").hide(); }) $(".Manual .colse").click(function(){ $(".Manual").hide(); }) //人工汇款弹窗 结束
//悬浮框
(“.Navd5”).click(function()varspeed=200;//滑动的速度$(‘body,html′).animate(scrollTop:0,speed);returnfalse;);(“.Navd2”).mouseenter(function(){
$(".num_cat").addClass('mouse').siblings().removeClass('mouse'); var index = $(".num_cat").addClass("num_cat_active");
}).mouseleave(function(){
$(“.num_cat”).removeClass(‘num_cat_active’);
}); //悬浮框购物车样式
var $imforId = ""; //保存当前行id totl(); adddel() //全选 $(".all").click(function() { if($(this).prop('checked')){ $('.imfor').css("background-color","#fffbf2"); } else{ $('.imfor').css("background-color","#fff"); } }) //删除当前行 $(".btn_del").click(function(){ $('.imfor').eq($imforId).remove(); $(".tip").hide(); /*$(this).click(function() { $(this).parent().remove(); $(".tip").hide(); if($(".imfor").length == 0) { $("#susum").text(0);//合计 } totl(); })*/ }) $(".del").click(function(){ $('.popup').find('.prodNum').val($(this).parents('.imfor').find('.prodNum').val()); $(".tip").show(); $imforId = $(this).parents('.imfor').index(); //alert($imforId) }) $(".popup .colse").click(function(){ $(".tip").hide(); }) $(".popup .btn_2").click(function(){ $(".tip").hide(); })//弹窗 $(".foot_add").click(function() { var str = '<div class="imfor">' + '<div class="check">' + '<input type="checkbox" class="Each" />' + '</div>' + '<div class="pudc"><img src="images/gold.png" /><span> 投资金条储值金砖正品保证支持回购</span></div>' + '<div class="pices">63240.6</div>' + '<div class="num"><div class="num_1"><span class="reduc"></span><input type="text" value="1" /><span class="add"></span></div></div>' + '<div class="totle">63240.6</div>' + '<div class="del">删除</div>' + '</div>'; $(this).parent().prev().append(str); totl(); adddel() $(".del").each(function() { $(this).click(function() { $(this).parent().remove(); totl(); }) }) }) //全选删除 $(".foot_del").click(function() { $(".tip").show(); $(".tip_002").show(); setTimeout(function () { $(".tip_002").hide(); }, 1000); }) $(".btn_del").click(function() { $(".Each").each(function() { if($(this).prop('checked')) { $(".tip").show(); $(this).parents(".imfor").remove(); totl(); if($(".imfor").length == 0) { $("#susum").text(0);//合计 } }else{} }) }) /*$(".tip_002").show(); setTimeout(function () { $(".tip_002").hide(); }, 1000);*///没选中提示 // 所有复选(:checkbox)框点击事件-加上背景 $(".check_style_1").bind('click',function(){ $("input[type=checkbox]").each(function(){ if(this.checked){ //this.checked = false; $(this).parents('.imfor').css("background-color","#fffbf2"); } else{ //this.checked = true; $(this).parents('.imfor').css("background-color","#fff"); } }); }) // 设为默认地址-点击事件-加上边框 $("#mr_fu li").bind('click',function(){ $(this).addClass("active").siblings().removeClass('active'); /*$("input[type=radio]").each(function(){ if($(this).checked){ $(this).checked = false; $(this).parents('li').css("border","1px solid #d9d9d9"); } else{ $(this).checked = true; $(this).parents('li').css("border","1px solid #ffc766"); } });*/ }) //*个人发票和公司发票二选一 $('.fapiao').focus(function(){ $(this).parents('.Ordinaryinvoice').siblings('.Ordinaryinvoice').find('.fapiao').attr('readonly','readonly'); //$(this).parents('.Ordinaryinvoice').siblings('.Ordinaryinvoice').find('.tip').show(); }) $('.fapiao').blur(function(){ if($(this).val() == ""){ $('.fapiaoinpLabel').addClass("active"); $(".tip_inv").show(); setTimeout(function () { $(".tip_inv").hide(); }, 1200); //过1.2秒 提示框消失 setTimeout(function () { $('.inpLabel').removeClass("active"); }, 1200); //过1.2秒 消失 $(this).parents('.Ordinaryinvoice').siblings('.Ordinaryinvoice').find('.fapiao').removeAttr('readonly'); } //$(this).parents('.Ordinaryinvoice').siblings('.Ordinaryinvoice').find('.tip').show(); }) }) //合计 function totl() { var sum = 0; var aa = 0; $(".totle").each(function() { sum += parseFloat($(this).text()); $("#susum").text(sum.toFixed(2));//合计 }) } //******************
function totl() {
var sum = 0;
var aa = 0;
(“.Each”).each(function() {
if ((this).attr(“checked”)) {
for (var i = 0; i < $(this).length; i++) {
sum += parseInt($(this).val()); aa += 1;alert(5) } } }); $(".num_good").text(aa); $("#susum").text(sum.toFixed(2));//合计
}
function adddel(){ //小计和加减 $(".add").each(function() { $(this).click(function() { var $multi = 0; var vall = $(this).prev().val(); vall++; $(this).prev().val(vall); e3ff $multi = parseFloat(vall) * parseFloat($(this).parent().prev().text()); $(this).parent().next().text(Math.round($multi)); totl(); }) }) //减 $(".reduc").each(function() { $(this).click(function() { var $multi1 = 0; var vall1 = $(this).next().val(); vall1--; if(vall1 <= 0) { vall1 = 1; } $(this).next().val(vall1); $multi1 = parseFloat(vall1) * parseFloat($(this).parent().prev().text()); $(this).parent().next().text(Math.round($multi1)); totl(); }) }) } //新增地址点击按钮 滚动
$(document).ready(function () {
/* 图片滚动效果 */ $(".mr_frbox").slide({ titCell: "", mainCell: ".mr_frUl ul", autoPage: true, effect: "leftLoop", autoPlay: true, vis: 3 }); /* 鼠标悬停图片效果 */
});
//表单验证
(function(){
//提交表单内容不能为空判断(‘.keep’).click(function(){
var myreg = /^1[3|5|8|7|9][0-9]\d{8}/;//验证手机号码的正确性if((‘.bill’).val() == ”){
(‘.fapiaoinpLabel′).addClass(“active”);(“.tip_inv”).show();
setTimeout(function () { (“.tip_inv”).hide(); }, 1200); //过1.2秒 提示框消失
setTimeout(function () { $(‘.inpLabel’).removeClass(“active”); }, 1200); //过1.2秒 消失
}else if (('.tel_tip').val() != "" && !myreg.test($(‘.tel_tip’).val())) {
$('.telinpLabel').addClass("active"); $(".tip_inv-tel").show(); setTimeout(function () { $(".tip_inv-tel").hide(); }, 1200); //手机号码electronic过1.2秒 提示框消失 setTimeout(function () { $('.inpLabel').removeClass("active"); }, 1200); //过1.2秒 消失 }else{ $('.inpLabel').removeClass("active"); $(".tip_inv-1").show(); setTimeout(function () { $(".tip_inv-1").hide(); }, 1200); //过1.2秒 提示框消失 $(".VATinvoiceorder .btn_02").click(function(){ $(".tip_inv-1").hide(); $(".section_third").show(); $(".section_one").hide(); $(".section_two").hide(); }) } }); $('.keep_three').click(function(){ var myreg = /^1[3|5|8|7|9][0-9]\d{8}$/; //验证手机号码的正确性 if($('.bill_Name').val() == ''){ $('.fapiaoinpLabel').addClass("active"); $(".tip_inv").show(); setTimeout(function () { $(".tip_inv").hide(); }, 1200); //过1.2秒 提示框消失 setTimeout(function () { $('.fapiaoinpLabel').removeClass("active"); }, 1200); //过1.2秒 消失 }else if($('#comments').val() == ''){ $('.fapiaoinpLabel').addClass("active"); $(".tip_inv").show(); setTimeout(function () { $(".tip_inv").hide(); }, 1200); //过1.2秒 提示框消失 setTimeout(function () { $('.fapiaoinpLabel').removeClass("active"); }, 1200); //过1.2秒 消失 }else if ($('.tel_tip').val() != "" && !myreg.test($('.tel_tip').val())) { $('.telinpLabel').addClass("active"); $(".tip_inv-tel").show(); setTimeout(function () { $(".tip_inv-tel").hide(); }, 1200); //手机号码electronic过1.2秒 提示框消失 setTimeout(function () { $('.inpLabel').removeClass("active"); }, 1200); //过1.2秒 消失 }else{ $('.inpLabel').removeClass("active"); $(".tip_inv-1").show(); setTimeout(function () { $(".tip_inv-1").hide(); }, 1200); //过1.2秒 提示框消失 } }); });
//表单验证结束
相关文章推荐
- 用正则表达式和javascript对表单进行全面验证
- 用ASP动态生成JavaScript的表单验证代码
- JavaScript通用表单验证函数
- ASP动态生成的javascript表单验证代码。
- HTML表单javascript验证通用模式
- Html表单javascript 验证通用模式(收藏)
- ASP动态生成的javascript表单验证代码
- 用正则表达式和javascript对表单进行全面验证
- 为html表单域添加属性实现表单的javascript验证
- 用正则表达式和javascript对表单进行全面验证
- javascript进行页面表单验证格式
- 用Javascript 验证表单提交
- 一个非常强大完整的web表单验证程序(javascript)
- 用正则表达式和javascript对表单进行全面验证
- javaScript技巧(2):表单提交验证类
- ASP动态生成的javascript表单验证代码
- javaScript技巧(2)表单提交验证类
- javascript 验证表单 正则表达式
- Javascript客户端表单验证框架(JSValidation)
- 用正则表达式和javascript对表单进行全面验证