/*-----------------------------------------------------------*/ /*copyright by 动力无限 www.btoe.cn*/ /*邮箱 btoe@btoe.cn*/ /*合作电话 400-0599-360*/ /*版权所有违者必究*/ /*-----------------------------------------------------------*/ /*! * index_style_lq_menu v1.1.1 用于判断有三级菜单的时候,显示右侧小三角形 */ $(function () { $('.sanji_xiala_di').css('display',"none") $('.erji_xiala > i').each(function () { if($(this).find('.sanji_xiala').children().length>0){ $(this).find('.sanji_xiala_di').show() } }) }) //提交 $(function () { var placetxt1 = $('.username').attr('placeholder'), placetxt2 = $('.usertel').attr('placeholder'), placetxt3 = $('.useremail').attr('placeholder'), placetxt5 = $('.codetext').attr('placeholder'), placetxt4 = $('.xqcontent').attr('placeholder'); function inputblur(inputdom, placetxt) { $(inputdom).blur(function() { $(this).parent().removeclass('focus'); $(this).attr('placeholder', placetxt); }); } inputblur('.username', placetxt1); inputblur('.usertel', placetxt2); inputblur('.useremail', placetxt3); inputblur('.codetext', placetxt5); inputblur('.xqcontent', placetxt4); $('.inputmess').focus(function() { $(this).parent().addclass('focus'); $(this).attr('placeholder', ''); }); $('.submit-btn').on('click', function () { var kcontent = $('.xqcontent').val(); var kuser = $('.username').val(); var kphone = $('.usertel').val(); var kcode = $('.codetext').val().trim(); // var kemail = $('.useremail').val(); var reg = /(^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$)|(^((\(\d{3}\))|(\d{3}\-))?(1[3578]\d{9})$)|(^400[0-9]{7})/; if (kuser == "") { alert('姓名不能为空!') $(".username").focus(); return false; } if (kphone == "") { alert('号码不能为空!') $(".usertel").focus(); return false; } if(!reg.test(kphone)) { alert('号码填写有误!') $(".usertel").focus(); return false; } if (kcontent == "" || kcontent.length < 10) { alert('留言内容必须大于10字!') $(".xqcontent").focus(); return false; } if (kcode == "") { alert('验证码不能为空') $(".codetext").focus(); return false; } $.post('/api/message.ashx?action=add', { "kcontent": '信息:' + kcontent, "kuser": kuser, "kphone": kphone, "kcode": kcode }, function (res) { if (res == '1') { alert("留言提交成功"); $('.xqcontent').val(''); $('.username').val(''); $('.usertel').val(''); $('.codetext').val(''); }else { alert("留言提交失败") } }) }) }) //点击验证码刷新 $("#imgcode").click(function () { $(this)[0].src = '/api/message.ashx?action=code&' + math.random() });