项目需要完成的文本输入框字符数量限制器,自己使用感觉还不错,特推荐给大家。
1.源码
/*
* wordlimitor 1.0.1
* Date: 2011-08-01
* (c) 20011 gudufy,http://gudufy.cnblogs.com/
*
* This is licensed under the GNU LGPL, version 2.1 or later.
* For details, see: http://creativecommons.org/licenses/LGPL/2.1/
*/
$(function () {
$.fn.wordlimitor = function () {
$(this).each(function (i) {
if ($(this).nextAll('div.textlimit').size() == 0) {
$(this).after('<div class="textlimit">0</div>');
}
$(this).bind('propertychange focus keyup input paste', function () {
var _max = $(this).attr('max');
var _length = $(this).val().length;
if (_length > _max) {
$(this).val($(this).val().substring(0, _max));
}
_left = $(this).offset().left;
_top = $(this).offset().top;
_width = $(this).width();
_height = $(this).height();
$(this).nextAll('div.textlimit').html(_length + '/' + _max);
$(this).nextAll('div.textlimit').css({
'left': _left + _width + 15,
'top': _top + _height - 12
});
});
$(this).focus(function () {
$(this).nextAll('div.textlimit').fadeIn('slow');
});
$(this).blur(function () {
$(this).nextAll('div.textlimit').fadeOut('slow');
});
});
};
$('textarea[max],input[max]').wordlimitor();
});
2.使用(引入wordlimitor文件,直接在要限制的input控件上填写max=“要限制的字符数”即可)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>字符限制器</title>
<style type="text/css">
.textlimit {
position:absolute;
font-size:9pt;
color:#4586b5;
font-size:16px;
font-weight:bold;
font-family:Arial;
display:none;
}
</style>
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="jquery.wordlimitor-1.0.1.js" type="text/javascript"></script>
</head>
<body>
<p>单行限制:<input type="text" size="40" max="50" /></p>
<p>多行限制:<textarea rows="4" cols="40" max="200"></textarea></p>
<br />
<a href="mailto:gudufy@163.com">提建议</a>
</body>
</html>
3.下载
一、sql server数据库
SELECT SERVERPROPERTY('productversion') as version
今天用移动硬盘做项目,中午看WWE的时候不知道怎么回事,突然在资源管理器找不到我的移动硬盘盘符了,于是我重新把硬盘拨了下来插上去,运行程序,提示:
“/”应用程序中的服务器错误。 --------------------------------------------------------------------------------
在从服务器接收结果时发生传输级错误。 (provider: 共享内存提供程序, error: 0 - 管道的另一端上无任何进程。)
这时我跑到SQL管理器去看,发现本程序所用数据库的表一个都没有了,天啊,简直崩溃.......于是我头脑发热,把这个数据库删了(现在想想应该把它“分离”,再“附加”,可能就没事了)。删了之后才悔之晚矣,于是赶紧百度,发现一个叫“undelete_plus”的软件,下下来试试看吧,找是找到两个数据库文件,不过都不能用。后来就找到了一个叫“ActiveUndelete”的文件。
下载地址:http://www.05sun.com/down/9102.html
下面介绍一下使用方法:
一、下载之后解压,运行“Undelete.exe”这个文件。可以看到以下窗口(如果没有注册会提示你进行注册,解压目录里有注册机)

二、选择你要恢复的分区,右键选择“Scan”,如下图

三、在弹出的窗口中选择“Quick Scan”,然后点击“Scan”按钮,如下图

四、这时软件会自动搜索已经删除了的文件,并会以原文件目录形式展示出来,甚至连文件名都一样哦:)

五、选择你要恢复的文件夹或文件,然后点击那个像“刷新”的图标

六、接下来在弹出的窗口中选择你要保存的文件夹,其它选项保持默认即可,最后按“Recover”按钮,怎么样?很惊喜吧........

--还原sql数据库以后,不管怎么样也无法登陆论坛,仔细检查才发现,sql server表还是以前建立的用户,而又无法删除,解决方法:
declare tb cursor local for
select 'sp_changeobjectowner ''['+replace(user_name(uid),']',']]')+'].['
+replace(name,']',']]')+']'',''dbo'''
from sysobjects
where xtype in('U','V','P','TR','FN','IF','TF') and status>=0
open tb
declare @s nvarchar(4000)
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
go
复制以上代码在查询分析器里运行即可。