这是留言板的界面,当用户点击提交留言的时候,自动提交到我的留言下面
留言内容中为空,或者为灰色的“没有填写留言内容”都会弹出 请填写留言内容,当用户填写信息的会在右下角显示当前留言的字数。
下面是javascript的代码
//去掉左右尖括号 并用去掉空格后的字符串替代显示
function replaceBrackets(id) {
var inputValue = $("#" + id).val();
while (inputValue.indexOf("<") != -1) {
inputValue = inputValue.replace("<", "[");
}
while (inputValue.indexOf(">") != -1) {
inputValue = inputValue.replace(">", "]");
}
while (inputValue.indexOf("&") != -1) {
inputValue = inputValue.replace("&", " ");
}
$("#" + id).val(inputValue);
}
function replaceChar(name, char) {
var inputValue = $("#" + name).val();
while (inputValue.indexOf(char) != -1) {
inputValue = inputValue.replace(char, "");
}
return inputValue;
}
$("#txtMessage").blur(function () {
$("#txtMessage").val(replaceChar("txtMessage", "<!--"));
if ($("#txtMessage").val() == "") {
document.getElementById("txtMessage").style.color = "#8C8C8C";
$("#txtMessage").val("没有填写留言内容");
return false;
}
replaceBrackets("txtMessage");
return true;
});
$("#txtMessage").focus(function () {
if ($("#txtMessage").val() == "没有填写留言内容") {
document.getElementById("txtMessage").style.color = "#000000";
$("#txtMessage").val("");
}
});
function txtanum(id, name) //统计txta的输入字数
{
var maxl = 151;
var num = 150;
var content = $("#" + id).val();
content.slice(0, maxl);
var nowlength = content.length;
if (nowlength >= 0) {
if (nowlength < num)
$("#" + name).text(nowlength);
else
$("#" + name).text(num);
} else
$("#" + id).val(content.substring(0, maxl - 1));
if (nowlength == 0)
$("#" + name).text(0);
if (nowlength > num)
$("#" + id).val(content.substring(0, num));
}
var isSubmit = false;
$('#subMessage').click(function () {
if (isSubmit) {
return;
}
isSubmit = true;
if ($("#txtMessage").val() == "没有填写留言内容" || $.trim($("#txtMessage").val()) == "") {
alert("请输入留言内容!");
isSubmit = false;
return;
}
$.ajax({
type: "POST",
url: app_param.path_context+"/user/member/msgboard/save",
data: { "context": ($("#txtMessage").val()) },
error: function () {
isSubmit = false;
},
success: function (data) {
if (data) {
addRow(data);
isSubmit=false;
$('#zanwu').hide();
document.getElementById("txtMessage").style.color = "#8C8C8C";
$("#txtMessage").val("没有填写留言内容");
}
}
});
function addRow(messageboard) {
var table = $("#tblmsg");
var html = [];
html.push("<tr>");
html.push("<td class='m_time'>");
html.push(messageboard.createDate);
html.push("</td>");
html.push("<td>");
html.push(messageboard.context);
html.push("</td>");
html.push("<td style='border-right: 0;' class='m_order_procz'>");
html.push("<a class='xxx' href='messagereply/"+messageboard.id+"'>查看</a>");
html.push("</td>");
html.push("</tr>");
html = html.join('');
table.append(html);
}
});
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com
暂无“ajax无刷新评论功能”评论...
更新日志
2025年11月05日
2025年11月05日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]
