原订阅邮件所使用的JS文件transport.js和JQuery冲突,会更改transport.js文件,用以下代码可同样实现订阅功能。
<input type="text" id="user_email" class="inputBg" />
<input type="button" id="bnt_blue" value="{$lang.email_list_ok}"/>
<input type="button" id="bnt_bonus" value="{$lang.email_list_cancel}" />
/*邮件订阅*/
$("#bnt_blue").click(function() {
var email = $("#user_email").val();
if (check_email(email)) {
$.ajax({
type: "get",
url: "user.php?act=email_list",
data: 'job=add&email=' + email,
success: function(data) {
alert(data);
}
});
}
});
/*取消订阅*/
$("#bnt_bonus").click(function() {
var email = $("#user_email").val();
if (check_email(email)) {
$.ajax({
type: "get",
url: "user.php?act=email_list",
data: 'job=del&email=' + email,
success: function(data) {
alert(data);
}
});
}
}); function check_email(str) {
res = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var re = new RegExp(res);
if (str.match(re)) {
return true;
} else {
alert("请输入正确的E-mail地址");
return false;
}
}