document.write("验证码: \"点击刷新\""); function repid(plid,fid){ $("#repid").val(plid); $("#saytext").focus(); $('#tosayp').html('#回复'+fid+'楼# 取消'); } $('#tosayp').click(function(){ $('#tosayp').html(''); $("#repid").val(''); }); $(function(){ $('#saytext').bind("blur focus keydown keypress keyup", function(){ recount(); }); $("#sub_btn").live('click',function(){ var saytext = $("#saytext").val(); var nid = $("#id").val(); var classid = $("#classid").val(); var repid = $("#repid").val(); var key = $("#key").val(); var nomember = $("#nomember").val(); if(saytext==""){ $("#msg").show().html("你想说点什么呢?").fadeOut(3600); $("#saytext").focus(); return false; } if(key==""){ $("#msg").show().html("验证码不能为空!").fadeOut(3600); $('#key').focus(); return false; } $.ajax({ type: "POST", url: "/e/extend/Ajaxpl/doaction.php", dataType: "html", data: {'enews':'AddPl','saytext':saytext,'id':nid,'classid':classid,'repid':repid,'key':key,'nomember':nomember}, beforeSend:function(){ $('#counter').show().html('正在提交...'); $('#sub_btn').attr('disabled','disabled'); }, success: function(msg){ if(msg.length>=100){ $('#infocommentarea').prepend(msg); $("#msg").show().html("恭喜,发布成功!").fadeOut(2000); $('#saytext').val(''); $("#repid").val(''); $("#key").val(''); $('#tosayp').html(''); recount(); }else{ if(msg=="FailKey"){ $("#msg").show().html("验证码错误").fadeOut(3600); $('#key').focus(); }else if(msg=="OutKeytime"){ $("#msg").show().html("验证码过期").fadeOut(3600); $('#key').focus(); }else{ $("#msg").show().html(msg).fadeOut(3600); $('#saytext').focus(); } recount(); } } }); return false; }); }); function recount(){ var maxlen=140; var current = maxlen-$('#saytext').val().length; $('#counter').html('你还可以输入'+current+'个字'); if(current<0 || current>maxlen){ $('#counter').css('color','#D40D12'); $('#sub_btn').attr('disabled','disabled'); $('#counter').show().html("字数超过允许最大输入!"); }else $('#sub_btn').removeAttr('disabled'); if(current<10) $('#counter').css('color','#D40D12'); else if(current<20) $('#counter').css('color','#5C0002'); else $('#counter').css('color','#555'); }