主题 : 获取验*码疑惑
级别: 白丁
UID: 11130
积分:1 加为好友
威望: 0 精华: 0
主题:0 回复:1
注册时间:2010-09-20
在线时长:0
1#   发表于:2010-10-21 14:11:41  IP:219.239.*.*
这是用户注册要填写的验证码的文本框,他没有触发事件,怎么获取验证码的?

<input type="text" id="checkCode" name="checkCode" class="input required" />

谢谢指点
级别: 秀才
UID: 551
积分:96 加为好友
威望: 0 精华: 0
主题:4 回复:71
注册时间:2009-08-20
在线时长:0
2#   发表于:2010-10-22 18:08:13  IP:113.70.*.*
调用了后台的Servlet。

$(function(){
new JCore.CheckCode($('#checkCode'),'/CheckCode.svl');
$('#loginName').focus();
});


<servlet>
<servlet-name>jcaptcha</servlet-name>
<servlet-class>com.jeecms.common.checkcode.ImageCaptchaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jcaptcha</servlet-name>
<url-pattern>/CheckCode.svl</url-pattern>
</servlet-mapping>
级别: 秀才
UID: 551
积分:96 加为好友
威望: 0 精华: 0
主题:4 回复:71
注册时间:2009-08-20
在线时长:0
3#   发表于:2010-10-22 18:09:55  IP:113.70.*.*
/**
 * @param input
 *            验证码输入框jquery对象。
 * @param url
 *            验证码的url地址。
 * @param top
 *            上下偏移量。
 */
JCore.CheckCode.cssClass = 'j-chkcode';
JCore.CheckCode.url = '/CheckCode.svl';
JCore.CheckCode = function(input, url, top) {
this.input = input;
this.url = url || JCore.CheckCode.url;
this.top = top || 45;
this.imgLayer = null;
this.img = null;
this.event = null;
this.isShow = false;
var o = this;
var showImg = function() {
if (o.imgLayer == null) {
o.createHtml();
}
if (!o.isShow) {
var d = new Date().getTime();
o.img.attr('src', o.url + '?d=' + d);
var offset = o.input.offset();
o.imgLayer.show();
o.imgLayer.css('top', offset.top - o.top + 'px');
o.imgLayer.css('left', offset.left + 'px');
o.isShow = true;
}
};
var hideImg = function() {
if (o.isShow) {
o.event = setTimeout(function() {
o.imgLayer.hide();
o.isShow = false;
}, 200);
}
};
this.input.bind('focus', showImg);
this.input.bind('blur', hideImg);
};
JCore.CheckCode.prototype.createHtml = function() {
this.imgLayer = $('<div/>');
this.img = $('<img border="0" alt="验证码看不清楚?请点击刷新验证码"/>');
var o = this;
this.img.bind('click', function() {
o.input.focus();
if (o.event) {
clearTimeout(o.event);
}
this.src = o.url + '?d=' + new Date().getTime();
});
this.img.appendTo(this.imgLayer);
this.imgLayer.appendTo(document.body);
this.imgLayer.addClass('j-chkcode');
};
级别: 白丁
UID: 11130
积分:1 加为好友
威望: 0 精华: 0
主题:0 回复:1
注册时间:2010-09-20
在线时长:0
4#   发表于:2010-10-25 14:19:29  IP:219.239.*.*
谢谢了……
1 共1页