博文

目前显示的是标签为“Javascript”的博文

改进EXTJS的maxlength设置

在写Extjs3的时候,发现textfield输入框的maxlength设置之后不能限制输入的长度,只能在输入超出maxlength之后给出错误提示。 Google之后,发现可以把下段代码放入程序,一起加载就可以解决这个问题。 // To fix the maxlength property // if the textfield sets {maxlength} property, it cannot be inputted more than {maxlength} characters. // before fixing, the textfield can be inputted any amount of characters. When it lose focus, the validation messages will show. Ext.form.TextField.prototype.size = 255; Ext.form.TextField.prototype.initValue = function() { if(this.value !== undefined){ this.setValue(this.value); }else if(this.el.dom.value.length > 0){ this.setValue(this.el.dom.value); } this.el.dom.size = this.size; if (!isNaN(this.maxLength) && (this.maxLength *1) > 0 && (this.maxLength != Number.MAX_VALUE)) { this.el.dom.maxLength = this.maxLength *1; } };

去掉开心网讨厌的验证码

图片
好多开心网(kaixin001.com)的玩家都拥有好几个帐号,一起为自己的主号做贡献,但是在切换帐号登录的时候总是要输入繁琐的中文验证码,非常烦人。 我在登录开心网的时候,发现程序会先向cookie中写入一个字符串,再切换帐号登录的时候检测这个字符串是否存在,如果存在就要进入输入验证码的登录页面。 知道原理之后,就可以利用Firefox+Greasemonkey插件或者Chrome直接安装我写的这个脚本,就可以去除开心网的验证码了。 用安装Greasemonkey插件的Firefox浏览器或者Google Chrome浏览器登录这个网址: http://userscripts.org/scripts/show/55235 , 点击Install按钮,安装脚本之后,再试试用不同帐号登录开心网吧。 PS1: Greasemonkey插件安装地址: https://addons.mozilla.org/en-US/firefox/addon/748/ PS2: 还在用IE的用户,尤其是IE6用户,赶快放弃IE,改用Firefox或者Chrome吧。