function onsubmit() { if (!isreginput(0, "txtfeedback_title", "notempty", "请输入标题", 1, 255)) return false; if (!isreginput(0, "txtfeedback_person", "notempty", "请输入您的名字", 1, 50)) return false; //if (!isreginput(0, "txtfeedback_address", "notempty", "请输入您的地址", 1, 255)) return false; if (!isreginput(0, "txtfeedback_tel", "intege", "请输入您的联系电话", 1, 11)) return false; //if (!isreginput(0, "txtfeedback_fax", "intege", "请输入您的传真", 1, 12)) return false; //if (!isreginput(0, "txtfeedback_qq", "notempty", "请输入您的qq/msn/skype", 1, 50)) return false; if (!isreginput(0, "txtfeedback_email", "email", "请输入您的邮箱", 1, 50)) return false; if (!isreginput(0, "txtfeedback_code", "notempty", "请输入验证码", 1, 50)) return false; if (!checkcode()) { hintdialog('txtfeedback_code', "验证码错误", 0); return false; } if (!isreginput(0, "txtfeedback_content", "notempty", "请输入留言详细内容", 1, 1000)) return false; ajaxsubmit(); } //ajax提交表单 function ajaxsubmit() { var url = "ajax/ajax_feedback.aspx?action=add&"+getobjstring(); $.ajax({ url: url, cache: false, async: false, datatype: "text", success: function(data) { if (data == "true") { alert("感谢您的反馈"); window.location.reload(); } else if(data=="mailerr") { alert("感谢您的反馈,邮箱提醒发送失败");return false; } else { alert("反馈失败"); return false; } }, error: function() { alert("ajax error"); return false; } }); } function getformdata() { var datastr = "s=" + math.random(); $(":input[id]").each(function(index, domele) { var idname = $(domele).attr("id"); datastr = datastr + "&" + $(domele).attr("id") + "=" + encodeuricomponent($(domele).val()); }); return (datastr); } function clearinputdata() { $(":text").val(""); $("#txtfeedback_content").val(""); } function getobjstring(){ var datastr = "s=" + math.random(); $(":input[id]").each(function(index,domele){var idname = $(domele).attr("id");if(idname!="__viewstate" && idname!="__eventvalidation"){datastr = datastr + "&" + $(domele).attr("id") + "=" + encodeuricomponent($(domele).val());}}) // alert(datastr); return datastr; } function checkcode() { var url = "ajax/ajax_feedback.aspx?action=checkcode&txtfeedback_code=" + encodeuricomponent($("#txtfeedback_code").val()); var bool = true; $.ajax({ url: url, cache: false, async: false, datatype: "text", success: function(data) { // alert(data); if (data == "ok") { } else if (data == "error") { bool = false; } else { bool = false; } }, error: function() { bool = false; } }); return bool; }