var issubmit = false; $(document).ready(function () { //在线订车 if ($("#ly").size() > 0) { $("#btnok").click(function () { if (issubmit == true) { alert("您已经提交过了 不能重复提交"); return false; } try { if (trim($("#name").val()).length == 0){ alert("请填写姓名"); return false; } if (trim($("#phone").val()).length == 0){ alert("请填写手机"); return false; } if (checkmobil($("#phone").val())==false){ alert("手机格式错误"); return false; } if(trim($("#email").val()).length == 0){ alert("请填写邮箱"); return false; } if(checkemail($("#email").val())==false){ alert("邮箱格式错误"); return false; } if(trim($("#content").val()).length == 0){ alert("请填个人简历"); return false; } $('body').append("
"); $("#solutionfromdiv").html($("#ly").clone().attr("id", "solutionfromcopy")); var imputelement = $("#solutionfromcopy").find("input:text") var inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).replacewith(imputelement.eq(j).val()); } imputelement = $("#solutionfromcopy textarea") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).replacewith($("#ly textarea").eq(j).val()); } imputelement = $("#solutionfromcopy").find("input:radio") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { if (imputelement.eq(j).attr("checked") != "checked") { imputelement.eq(j).parent().html(""); } else { var radioval = imputelement.eq(j).val(); imputelement.eq(j).parent().html(radioval); } } imputelement = $("#solutionfromcopy").find("select") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).replacewith($("#ly select").eq(j).val()); } imputelement = $("#solutionfromcopy").find("input:submit") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).parent().html(""); } imputelement = $("#solutionfromcopy").find("input:button") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).parent().html(""); } imputelement = $("#solutionfromcopy").find("input:reset") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).parent().html(""); } imputelement = $("#solutionfromcopy").find("img") inputcount = imputelement.size() for (var j = 0; j < inputcount; j++) { imputelement.eq(j).parent().html(""); } var content = $("#solutionfromdiv").html(); var title = " 提交人:" + $("#name").val(); var summary = ""; var scid = $("#scid").html(); submitcomment(1, scid, title, content, summary); } catch (e) { alert(e); } }) } $("#btnclear").click(function () { $("#name").val(""); $("#phone").val(""); $("#email").val(""); $("#content").val(""); }) }) function submitcomment(wid, scid, title, content, summary) { var link = "/ihandler/submitmsg.ashx?timespan=" + new date().gettime(); $.post(link, { "wid" : wid, "scid" : scid, "title" : escape(title), "summary" : escape(summary), "content" : escape(content) }, function (data) { if (data.success == true) { issubmit = true; alert("提交成功"); } else { alert(data.error); } }) } function checkmobil(tel){ var reg=/^(0?1[358]\d{9})|((0(10|2[1-3]|[3-9]\d{2}))?[1-9]\d{6,7})$/; if(!reg.test(tel)){ return false; } return true; } function checkemail(email){ var reg=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if(!reg.test(email)){ return false; } return true; } function trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); }