//首页留言脚本
var ptn_email = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
//电话或者号码
var partten = /^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/;
//空字符
var reg = /^\s*$/;
///首页提交留言
function indexsendleaveword(src) {
var stxtmobileno = $v("txt_mobile");
var stxtcontact = $v("txt_name");
var stxtemail = $v("txt_mail");
var stxtadder = $v("txt_add");
var stxtadder2 = $v("txt_add2");
var stxtcontent = $v("txt_content");
var _vercode = $tv("txtcmtvercode");
var err = "";
if (reg.test(stxtcontact)) {
err += "
联系人不可为空";
}
if (reg.test(stxtemail)) {
err += "电子邮箱地址不可为空";
} else if (!ptn_email.test(stxtemail)) {
err += "电子邮箱地址格式错误";
}
if (reg.test(stxtmobileno)) {
err += "联系电话不可为空";
}
else if (!partten.test(stxtmobileno)) {
err += "手机格式错误";
}
// if (reg.test(stxtadder)) {
// err += "地址不可空";
// }
if (reg.test(stxtcontent)) {
err += "留言不可空";
}
if ($g("txtcmtvercode") == null || _vercode == "") {
$a("验证码不可空。");
//showproc(src, false);
return;
}
if (err.length > 0) {
$a(err);
return;
}
stxtadder += " 预约地址:" + stxtadder2;
showproc(src);
$.post("/ajax.ashx?action=indexaddagent&t=" + math.random(), {
contact: stxtcontact,
mobileno: stxtmobileno,
email: stxtemail,
adder: stxtadder,
content:stxtcontent,
vercode:_vercode
}, function (msg) {
var sta = gav(msg, "state");
var smsg = gav(msg, "msg");
if (sta == "1") {
//emptytext('oran_table_1');
$("#txt_name").val("");
$("#txt_mobile").val("");
$("#txt_mail").val("");
$("#txt_add").val("");
$("#txt_add2").val("");
$("#txt_content").val("");
$("#txtcmtvercode").val("");
$a(smsg, 1);
} else {
$("#txt_name").val("");
$("#txt_mobile").val("");
$("#txt_mail").val("");
$("#txt_add").val("");
$("#txt_add2").val("");
$("#txt_content").val("");
$("#txtcmtvercode").val("");
$a(smsg);
}
showproc(src, false);
});
}