function CheckInput() { var $txtLength = $("#inp_text").val().length; if ($txtLength > 10) { var url = $("#inp_text").val(); var xx = url.match(RegExp("((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*", "gi") || []); if (xx != null) { for (var i = 0; i < xx.length; i++) { var $txtLength = $("#inp_text").val().length; $txtLength = $txtLength - xx[i].length + 11; } } } if ($txtLength < 141) { $("#div_txtlength").html("还能输入" + (140 - $txtLength) + "个字"); } else { $("#div_txtlength").html("超出" + ($txtLength - 140) + "个字"); } } function InsertText() { if ($("#inp_text").val().Trim().length == 0) { art.dialog({ title: '错误', icon: 'error', content: '请输入内容', width: "150px", height: "80px", lock: true }); return; } //长url转换成短url var url = $("#inp_text").val(); var xx = url.match(RegExp("((news|telnet|nttp|file|http|ftp|https)://){1}(([-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)*(\\.[-A-Za-z]{2,5}))|([0-9]{1,3}(\\.[0-9]{1,3}){3}))(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*)*", "gi") || []); var $txtLength = $("#inp_text").val().length; if (xx != null) { for (var i = 0; i < xx.length; i++) { $txtLength = $txtLength - xx[i].length + 11; } } if ($txtLength < 141) { $("#div_txtlength").html("还能输入" + (140 - $txtLength) + "个字"); } else { $("#div_txtlength").html("超出" + ($txtLength - 140) + "个字"); } if ($txtLength > 140) { art.dialog({ title: '错误', icon: 'error', content: '字数超出限制', width: "150px", height: "80px", lock: true }); return false; } $.ajax({ type: "POST", url: "../MiniBlog/Handler.ashx", data: { "txt": $("#inp_text").val() }, datatype: "html", beforeSend: function () { $("#div_txtlength").html("正在提交。。。"); }, success: function (data) { if (data.length > 1) { window.location.reload(); } else { art.dialog({ title: '错误', icon: 'error', content: '发布失败,请复制内容后刷新当前页面。', width: "150px", height: "80px", lock: true }); } }, complete: function (XMLHttpRequest, textStatus) { // alert(XMLHttpRequest.responseText); // alert(textStatus); }, error: function () { } }); } //csharp/6655