function mailValid(){ //alert(downloadmail) $("#downloadmailerrortip").html(""); var errortip = ""; //^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$ //^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$ var reg = new RegExp("^[a-z0-9A-Z]+([._\\-]*[a-z0-9A-Z])*@([a-zA-Z0-9]+[-a-z0-9A-Z]*[a-z0-9A-Z]+.){1,63}[a-z0-9A-Z]+$"); //正则表达式 var emailvalue = $("#downloadmail").val(); //alert(emailvalue) if(emailvalue){ if(!reg.test(emailvalue)){ //正则验证不通过,格式不对     errortip = "邮箱格式不正确!"; } }else{ errortip = "请输入您的邮箱!";   } if(errortip){ $("#downloadmailerrortip").html(errortip); return false; }else{ return true; //return false; } } function downLoadWinClose(){ //$("#downloadtomailwin").css("display","none"); $('#dialogBg5').fadeOut(300, function () { $('#dialog5').addClass('bounceOutUp').fadeOut(); }); } /** * */ function downLoadWinShow(thisp,fileUrl,fileName){ className = $(thisp).attr('class'); $('#dialogBg5').fadeIn(300); $('#dialog5').removeAttr('class').addClass('animated ' + className + '').fadeIn(); //$("#downloadtomailwin").css("display",""); $("#downloadfileurl").val(fileUrl); $("#downloadfilename").val(fileName); } function downLoadLinkToMail(){ var downloadfileurl = $("#downloadfileurl").val(); var fileName = $("#downloadfilename").val(); var mailCheck = mailValid(); if(mailCheck){ var emailvalue = $("#downloadmail").val(); submitLinkToMail(emailvalue,downloadfileurl,fileName); } } function submitLinkToMail(emailvalue,downloadfileurl,fileName){ $("#downLoadLinkToMailbtn").attr('disabled',true); $.ajax({ type: "post", url: "../sendenFileToMail.jspx", data: { emailvalue : emailvalue, fileName : fileName, fileUrl : downloadfileurl }, dataType: "json", success: function(data){ //$("#downLoadLinkToMailbtn").attr('disabled',"false"); $('#downLoadLinkToMailbtn').removeAttr("disabled"); if(data.success=='1'){ alert("Sending succeeded!"); downLoadWinClose(); }else{ alert("Fail in send!"); } }, failure :function(){ //$("#downLoadLinkToMailbtn").attr('disabled',"false"); $('#downLoadLinkToMailbtn').removeAttr("disabled"); alert("Sending failed, please contact the administrator!"); } }); } function downLoadByName(attachName,attachPath,atype){ //attachPath = "/u/cms/www/111.pdf" $.ajax({ type: 'POST', url: "../updateDownLoadCount.jspx", data: { attachName : attachName, attachPath : attachPath, atype : atype }, success: function(resp){ } }); if(attachPath && attachPath.indexOf("http")<0){ attachName = encodeURIComponent(attachName.trim()); if(atype == 1){ if(attachPath.indexOf(".pdf")>=0 || attachPath.indexOf(".PDF")>=0 ){ window.open("/en/downloadByName.jspx?isPreview=Y&filePath="+attachPath+"&fileName="+attachName+"&t=" + new Date()); }else{ window.open(attachPath); } }else{ //下载 window.open("/en/downloadByName.jspx?filePath="+attachPath+"&fileName="+attachName+"&t=" + new Date()); } } }