function addbook(companyname, name, email, tel, address, country, content) { $.ajax({ type: "post",//方法类型 url: "/ajaxdata.ashx",//url data: "action=addbook&companyname=" + escape(companyname) + "&name=" + escape(name) + "&email=" + escape(email) + "&tel=" + escape(tel) + "&address=" + escape(address) + "&country=" + escape(country) + "&content=" + escape(content), success: function (result) { if (result == 200) { alert("提交留言成功!"); } }, error: function () { alert("提交留言失败!"); } }); } function checkall() { var companyname, name, email, tel, address, country, content; companyname = $("#companyname").val(); name = $("#name").val(); email = $("#email").val(); tel = $("#tel").val(); address = $("#address").val(); country = $("#country").val(); content = $("#content").val(); if ($.trim(companyname) == "") { alert("请输入公司名称!"); $("#companyname").focus(); return false; } if ($.trim(name) == "") { alert("请输入姓名!"); $("#name").focus(); return false; } if ($.trim(email) == "") { alert("请输入您的邮箱!"); $("#email").focus(); return false; } else { if (!checkemail(email)) { alert("邮箱格式错误!"); $("#email").focus(); return false; } } if ($.trim(tel) == "") { alert("请输入电话!"); $("#tel").focus(); return false; } if ($.trim(address) == "") { alert("请输入您的地址!"); $("#address").focus(); return false; } if ($.trim(country) == "") { alert("请输入国家!"); $("#country").focus(); return false; } if ($.trim(content) == "") { alert("请输入留言内容描述!"); $("#content").focus(); return false; } addbook(companyname, name, email, tel, address, country, content); } //判断email格式是否正确 function checkemail(stremail) { if (stremail.trim().indexof('@') == "-1" || stremail.trim().indexof('.') == "-1") { return false; } else return true; } //首页提交 function indexsend() { var name, tel, text; name = $("#tbname").val(); tel = $("#tel").val(); text = $("#text").val(); if ($.trim(name) == "") { alert("请输入您的姓名!"); $("#tbname").focus(); return false; } if ($.trim(tel) == "") { alert("请输入您的电话!"); $("#tel").focus(); return false; } if ($.trim(text) == "") { alert("请输入您的建议!"); $("#text").focus(); return false; } addbook1(name, tel, text); } function addbook1(name, tel, text) { $.ajax({ type: "post",//方法类型 url: "/ajaxdata.ashx",//url data: "action=addbook1&name=" + escape(name) + "&tel=" + escape(tel) + "&text=" + escape(text), success: function (result) { if (result == 200) { alert("提交留言成功!"); } }, error: function () { alert("提交留言失败!"); } }); }