commit | author | age
|
19351a
|
1 |
//检查结果 |
B |
2 |
var _CHECK_RESULT = { |
|
3 |
// 邮箱检查结果是否可以注册 |
|
4 |
email: false, |
|
5 |
// 手机检查结果是否可以注册 |
|
6 |
mobile_phone: false |
|
7 |
}; |
|
8 |
|
|
9 |
function chkstr(str) { |
|
10 |
for (var i = 0; i < str.length; i++) { |
|
11 |
if (str.charCodeAt(i) < 127 && !str.substr(i, 1).match(/^\w+$/ig)) { |
|
12 |
return false; |
|
13 |
} |
|
14 |
} |
|
15 |
return true; |
|
16 |
} |
|
17 |
|
|
18 |
/** |
|
19 |
* 检查密码 |
|
20 |
* @param password |
|
21 |
* @returns {Boolean} |
|
22 |
*/ |
|
23 |
function check_password(password) { |
|
24 |
conform_password = document.getElementById('conform_password').value; |
|
25 |
if(password.indexOf(" ") != -1){ |
|
26 |
document.getElementById('password_notice').innerHTML = "登录密码不能包含空格"; |
|
27 |
document.getElementById('password_notice').style.color = "#E31939"; |
|
28 |
$("#pwd_notice").show(); |
|
29 |
$("#pwd_intensity").hide(); |
|
30 |
return false; |
|
31 |
}else if (password.length < 6) { |
|
32 |
document.getElementById('password_notice').innerHTML = password_shorter; |
|
33 |
document.getElementById('password_notice').style.color = "#E31939"; |
|
34 |
$("#pwd_notice").show(); |
|
35 |
$("#pwd_intensity").hide(); |
|
36 |
return false; |
|
37 |
} else if (conform_password.length > 0) { |
|
38 |
if (password != conform_password) { |
|
39 |
document.getElementById('password_notice').innerHTML = confirm_password_invalid; |
|
40 |
document.getElementById('password_notice').style.color = "#E31939"; |
|
41 |
$("#pwd_notice").show(); |
|
42 |
$("#pwd_intensity").hide(); |
|
43 |
return false; |
|
44 |
} else { |
|
45 |
document.getElementById('password_notice').innerHTML = msg_can_rg; |
|
46 |
document.getElementById('password_notice').style.color = "#093"; |
|
47 |
document.getElementById('conform_password_notice').innerHTML = msg_can_rg; |
|
48 |
document.getElementById('conform_password_notice').style.color = "#093"; |
|
49 |
$("#pwd_notice").hide(); |
|
50 |
$("#pwd_intensity").show(); |
|
51 |
} |
|
52 |
} else { |
|
53 |
document.getElementById('password_notice').innerHTML = msg_can_rg; |
|
54 |
document.getElementById('password_notice').style.color = "#093"; |
|
55 |
$("#pwd_notice").hide(); |
|
56 |
$("#pwd_intensity").show(); |
|
57 |
} |
|
58 |
return true; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* 检查确认密码 |
|
63 |
* @param conform_password |
|
64 |
* @returns {Boolean} |
|
65 |
*/ |
|
66 |
function check_conform_password(conform_password) { |
|
67 |
var password = document.getElementById('password').value; |
|
68 |
|
|
69 |
if(conform_password.indexOf(" ") != -1){ |
|
70 |
document.getElementById('conform_password_notice').innerHTML = "登录密码不能包含空格"; |
|
71 |
document.getElementById('conform_password_notice').style.color = "#E31939"; |
|
72 |
$("#conform_password_notice").show(); |
|
73 |
return false; |
|
74 |
}else if (conform_password.length < 6) { |
|
75 |
document.getElementById('conform_password_notice').innerHTML = password_shorter; |
|
76 |
document.getElementById('conform_password_notice').style.color = "#E31939"; |
|
77 |
return false; |
|
78 |
} |
|
79 |
if (conform_password != password) { |
|
80 |
document.getElementById('conform_password_notice').innerHTML = confirm_password_invalid; |
|
81 |
document.getElementById('conform_password_notice').style.color = "#E31939"; |
|
82 |
return false; |
|
83 |
} else { |
|
84 |
document.getElementById('conform_password_notice').innerHTML = msg_can_rg; |
|
85 |
document.getElementById('conform_password_notice').style.color = "#093"; |
|
86 |
return false; |
|
87 |
} |
|
88 |
return true; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* 验证邮箱,第一步合法性验证, 第二步是否存在验证 |
|
93 |
* |
|
94 |
* @param email |
|
95 |
* 验证邮箱:支持邮箱和邮箱对象 |
|
96 |
* @param callback |
|
97 |
* 回调函数:true-可以注册 false-不可以注册 |
|
98 |
*/ |
|
99 |
function checkEmail(email, callback) { |
|
100 |
var submit_disabled = false; |
|
101 |
|
|
102 |
var emailObj = null; |
|
103 |
|
|
104 |
if (typeof (email) == 'object') { |
|
105 |
emailObj = $(email); |
|
106 |
email = emailObj.val(); |
|
107 |
} |
|
108 |
|
|
109 |
if (email == '') { |
|
110 |
document.getElementById('email_notice').innerHTML = msg_email_blank; |
|
111 |
document.getElementById('email_notice').style.color = '#E31939'; |
|
112 |
submit_disabled = true; |
|
113 |
|
|
114 |
if (emailObj != null) { |
|
115 |
emailObj.focus(); |
|
116 |
} |
|
117 |
|
|
118 |
} else if (!Utils.isEmail(email)) { |
|
119 |
document.getElementById('email_notice').innerHTML = msg_email_format; |
|
120 |
document.getElementById('email_notice').style.color = '#E31939'; |
|
121 |
submit_disabled = true; |
|
122 |
|
|
123 |
if (emailObj != null) { |
|
124 |
emailObj.focus(); |
|
125 |
} |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
if (submit_disabled) { |
|
130 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
131 |
return false; |
|
132 |
} |
|
133 |
|
|
134 |
if (emailObj == null) { |
|
135 |
checkEmailExist(email, callback); |
|
136 |
} else { |
|
137 |
checkEmailExist(emailObj, callback); |
|
138 |
} |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* 检查邮箱是否已经绑定过用户 |
|
143 |
* |
|
144 |
* @param email |
|
145 |
* 验证邮件:支持邮箱和邮箱对象 |
|
146 |
* @param callback |
|
147 |
* 回调函数:true-可以注册 false-不可以注册 |
|
148 |
*/ |
|
149 |
function checkEmailExist(email, callback) { |
|
150 |
|
|
151 |
var emailObj = null; |
|
152 |
|
|
153 |
if (typeof (email) == 'object') { |
|
154 |
emailObj = $(email); |
|
155 |
email = emailObj.val(); |
|
156 |
} |
|
157 |
|
|
158 |
$.post('register.php?act=check_email_exist', { |
|
159 |
email: email |
|
160 |
}, function(result) { |
|
161 |
if (result == 'false') { |
|
162 |
document.getElementById('email_notice').innerHTML = msg_can_rg; |
|
163 |
document.getElementById('email_notice').style.color = '#093'; |
|
164 |
document.forms['formUser'].elements['Submit'].disabled = ''; |
|
165 |
|
|
166 |
if ($.isFunction(callback)) { |
|
167 |
callback(true); |
|
168 |
} |
|
169 |
} else { |
|
170 |
document.getElementById('email_notice').innerHTML = msg_email_registered; |
|
171 |
document.getElementById('email_notice').style.color = '#E31939'; |
|
172 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
173 |
|
|
174 |
if (emailObj != null) { |
|
175 |
emailObj.focus(); |
|
176 |
} |
|
177 |
|
|
178 |
if ($.isFunction(callback)) { |
|
179 |
callback(false); |
|
180 |
} |
|
181 |
|
|
182 |
} |
|
183 |
}, 'text'); |
|
184 |
} |
|
185 |
|
|
186 |
function checkMobile(sMobile){ |
|
187 |
if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(sMobile))){ |
|
188 |
return false; |
|
189 |
} |
|
190 |
else |
|
191 |
{ |
|
192 |
return true; |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
function checkMobilePhone(mobile, callback) { |
|
197 |
var submit_disabled = false; |
|
198 |
|
|
199 |
var mobileObj = null; |
|
200 |
|
|
201 |
if (typeof (mobile) == 'object') { |
|
202 |
mobileObj = $(mobile); |
|
203 |
mobile = mobileObj.val(); |
|
204 |
} |
|
205 |
|
|
206 |
if (mobile == '') { |
|
207 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_blank; |
|
208 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
209 |
submit_disabled = true; |
|
210 |
|
|
211 |
if (mobileObj != null) { |
|
212 |
mobileObj.focus(); |
|
213 |
} |
|
214 |
|
|
215 |
} else if (!Utils.isMobile(mobile)) { |
|
216 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_format; |
|
217 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
218 |
submit_disabled = true; |
|
219 |
|
|
220 |
if (mobileObj != null) { |
|
221 |
mobileObj.focus(); |
|
222 |
} |
|
223 |
} else if(!checkMobile(mobile)){ |
|
224 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_format; |
|
225 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
226 |
submit_disabled = true; |
|
227 |
|
|
228 |
if (mobileObj != null) { |
|
229 |
mobileObj.focus(); |
|
230 |
} |
|
231 |
} |
|
232 |
|
|
233 |
if (submit_disabled) { |
|
234 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
235 |
return false; |
|
236 |
} |
|
237 |
|
|
238 |
if (mobileObj == null) { |
|
239 |
checkMobilePhoneExist(mobile, callback); |
|
240 |
} else { |
|
241 |
checkMobilePhoneExist(mobileObj, callback); |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
var cur_mobile_phone = null; |
|
246 |
function checkMobilePhoneExist(mobile, callback) { |
|
247 |
var mobileObj = null; |
|
248 |
|
|
249 |
if (typeof (mobile) == 'object') { |
|
250 |
mobileObj = $(mobile); |
|
251 |
mobile = mobileObj.val(); |
|
252 |
} |
|
253 |
|
|
254 |
if (mobile == cur_mobile_phone && !$.isFunction(callback)) { |
|
255 |
return; |
|
256 |
} |
|
257 |
|
|
258 |
$.post('register.php?act=check_mobile_exist', { |
|
259 |
mobile: mobile |
|
260 |
}, function(result) { |
|
261 |
if (result == 'false') { |
|
262 |
document.getElementById('mobile_phone_notice').innerHTML = msg_can_rg; |
|
263 |
document.getElementById('mobile_phone_notice').style.color = '#093'; |
|
264 |
document.forms['formUser'].elements['Submit'].disabled = ''; |
|
265 |
|
|
266 |
if ($.isFunction(callback)) { |
|
267 |
callback(true); |
|
268 |
} |
|
269 |
} else { |
|
270 |
document.getElementById('mobile_phone_notice').innerHTML = msg_mobile_phone_registered; |
|
271 |
document.getElementById('mobile_phone_notice').style.color = '#E31939'; |
|
272 |
document.forms['formUser'].elements['Submit'].disabled = 'disabled'; |
|
273 |
|
|
274 |
if (mobileObj != null) { |
|
275 |
mobileObj.focus(); |
|
276 |
} |
|
277 |
|
|
278 |
if ($.isFunction(callback)) { |
|
279 |
callback(false); |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
cur_mobile_phone = mobile; |
|
284 |
|
|
285 |
}, 'text'); |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* 用户注册 |
|
290 |
* |
|
291 |
* @param register_type |
|
292 |
* 注册类型:email、mobile |
|
293 |
*/ |
|
294 |
function register(register_type) { |
|
295 |
if (register_type == "email") { |
|
296 |
return reg_by_email(); |
|
297 |
} else { |
|
298 |
return reg_by_mobile(); |
|
299 |
} |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* 通过邮箱注册 |
|
304 |
* |
|
305 |
* @returns {Boolean} |
|
306 |
*/ |
|
307 |
function reg_by_email() { |
|
308 |
var frm = document.forms['formUser']; |
|
309 |
// 邮箱注册时不支持用户名注册 |
|
310 |
// var username = Utils.trim(frm.elements['username'].value); |
|
311 |
var email = frm.elements['email'].value; |
|
312 |
var password = Utils.trim(frm.elements['password'].value); |
|
313 |
var confirm_password = Utils.trim(frm.elements['confirm_password'].value); |
|
314 |
var checked_agreement = frm.elements['agreement'].checked; |
|
315 |
var msn = frm.elements['extend_field1'] ? Utils.trim(frm.elements['extend_field1'].value) : ''; |
|
316 |
var qq = frm.elements['extend_field2'] ? Utils.trim(frm.elements['extend_field2'].value) : ''; |
|
317 |
var home_phone = frm.elements['extend_field4'] ? Utils.trim(frm.elements['extend_field4'].value) : ''; |
|
318 |
var office_phone = frm.elements['extend_field3'] ? Utils.trim(frm.elements['extend_field3'].value) : ''; |
|
319 |
// 邮箱注册不能绑定手机,许多注册成功后再绑定 |
|
320 |
// var mobile_phone = frm.elements['extend_field5'] ? |
|
321 |
// Utils.trim(frm.elements['extend_field5'].value) : ''; |
|
322 |
var passwd_answer = frm.elements['passwd_answer'] ? Utils.trim(frm.elements['passwd_answer'].value) : ''; |
|
323 |
var sel_question = frm.elements['sel_question'] ? Utils.trim(frm.elements['sel_question'].value) : ''; |
|
324 |
// 邮箱验证码 |
|
325 |
var email_code = frm.elements['email_code'] ? Utils.trim(frm.elements['email_code'].value) : ''; |
|
326 |
// 验证码 |
|
327 |
var captcha = frm.elements['captcha'] ? Utils.trim(frm.elements['captcha'].value) : ''; |
|
328 |
|
|
329 |
var msg = ""; |
|
330 |
// 检查输入 |
|
331 |
var msg = ''; |
|
332 |
|
|
333 |
if (email.length == 0) { |
|
334 |
msg += email_empty + '\n'; |
|
335 |
} else { |
|
336 |
if (!(Utils.isEmail(email))) { |
|
337 |
msg += email_invalid + '\n'; |
|
338 |
} |
|
339 |
} |
|
340 |
if (password.length == 0) { |
|
341 |
msg += password_empty + '\n'; |
|
342 |
} else if (password.length < 6) { |
|
343 |
msg += password_shorter + '\n'; |
|
344 |
} |
|
345 |
if (/ /.test(password) == true) { |
|
346 |
msg += passwd_balnk + '\n'; |
|
347 |
} |
|
348 |
if (confirm_password != password) { |
|
349 |
msg += confirm_password_invalid + '\n'; |
|
350 |
} |
|
351 |
if (checked_agreement != true) { |
|
352 |
msg += agreement + '\n'; |
|
353 |
} |
|
354 |
|
|
355 |
if (msn.length > 0 && (!Utils.isEmail(msn))) { |
|
356 |
msg += msn_invalid + '\n'; |
|
357 |
} |
|
358 |
|
|
359 |
if (qq.length > 0 && (!Utils.isNumber(qq))) { |
|
360 |
msg += qq_invalid + '\n'; |
|
361 |
} |
|
362 |
|
|
363 |
if (office_phone.length > 0) { |
|
364 |
var reg = /^[\d|\-|\s]+$/; |
|
365 |
if (!reg.test(office_phone)) { |
|
366 |
msg += office_phone_invalid + '\n'; |
|
367 |
} |
|
368 |
} |
|
369 |
if (home_phone.length > 0) { |
|
370 |
var reg = /^[\d|\-|\s]+$/; |
|
371 |
|
|
372 |
if (!reg.test(home_phone)) { |
|
373 |
msg += msg_email_code_blank + '\n'; |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
if ($("#email_code").size() > 0 && email_code.length == 0) { |
|
378 |
msg += msg_email_code_blank + '\n'; |
|
379 |
} |
|
380 |
|
|
381 |
if ($("#captcha").size() > 0 && captcha.length == 0) { |
|
382 |
msg += msg_captcha_blank + '\n'; |
|
383 |
} |
|
384 |
|
|
385 |
// if (mobile_phone.length > 0) { |
|
386 |
// var reg = /^[\d|\-|\s]+$/; |
|
387 |
// if (!reg.test(mobile_phone)) { |
|
388 |
// msg += mobile_phone_invalid + '\n'; |
|
389 |
// } |
|
390 |
// } |
|
391 |
if (passwd_answer.length > 0 && sel_question == 0 || document.getElementById('passwd_quesetion') && passwd_answer.length == 0) { |
|
392 |
msg += no_select_question + '\n'; |
|
393 |
} |
|
394 |
|
|
395 |
for (var i = 4; i < frm.elements.length - 4; i++) // 从第五项开始循环检查是否为必填项 |
|
396 |
{ |
|
397 |
var needinput = document.getElementById(frm.elements[i].name + 'i') ? document.getElementById(frm.elements[i].name + 'i') : ''; |
|
398 |
|
|
399 |
if (needinput != '' && frm.elements[i].value.length == 0) { |
|
400 |
msg += '- ' + frm.elements[i].placeholder + "不能为空!" + '\n'; |
|
401 |
//msg += '- ' + needinput.innerHTML + msg_blank + '\n'; |
|
402 |
} |
|
403 |
} |
|
404 |
|
|
405 |
if (msg.length > 0) { |
|
406 |
alert(msg); |
|
407 |
return false; |
|
408 |
} else { |
|
409 |
return true; |
|
410 |
} |
|
411 |
} |
|
412 |
|
|
413 |
function reg_by_mobile() { |
|
414 |
var frm = document.forms['formUser']; |
|
415 |
// 手机时不支持用户名注册 |
|
416 |
// var username = Utils.trim(frm.elements['username'].value); |
|
417 |
var mobile_phone = frm.elements['mobile_phone'].value; |
|
418 |
var password = Utils.trim(frm.elements['password'].value); |
|
419 |
var confirm_password = Utils.trim(frm.elements['confirm_password'].value); |
|
420 |
var checked_agreement = frm.elements['agreement'].checked; |
|
421 |
var msn = frm.elements['extend_field1'] ? Utils.trim(frm.elements['extend_field1'].value) : ''; |
|
422 |
var qq = frm.elements['extend_field2'] ? Utils.trim(frm.elements['extend_field2'].value) : ''; |
|
423 |
var home_phone = frm.elements['extend_field4'] ? Utils.trim(frm.elements['extend_field4'].value) : ''; |
|
424 |
var office_phone = frm.elements['extend_field3'] ? Utils.trim(frm.elements['extend_field3'].value) : ''; |
|
425 |
// 邮箱注册不能绑定手机,许多注册成功后再绑定 |
|
426 |
// var mobile_phone = frm.elements['extend_field5'] ? |
|
427 |
// Utils.trim(frm.elements['extend_field5'].value) : ''; |
|
428 |
var passwd_answer = frm.elements['passwd_answer'] ? Utils.trim(frm.elements['passwd_answer'].value) : ''; |
|
429 |
var sel_question = frm.elements['sel_question'] ? Utils.trim(frm.elements['sel_question'].value) : ''; |
|
430 |
// 手机验证码 |
|
431 |
var mobile_code = frm.elements['mobile_code'] ? Utils.trim(frm.elements['mobile_code'].value) : ''; |
|
432 |
// 验证码 |
|
433 |
var captcha = frm.elements['captcha'] ? Utils.trim(frm.elements['captcha'].value) : ''; |
|
434 |
|
|
435 |
var msg = ""; |
|
436 |
// 检查输入 |
|
437 |
var msg = ''; |
|
438 |
|
|
439 |
if (mobile_phone.length == 0) { |
|
440 |
msg += msg_mobile_phone_blank + '\n'; |
|
441 |
} else { |
|
442 |
if (!(Utils.isMobile(mobile_phone))) { |
|
443 |
msg += mobile_phone_invalid + '\n'; |
|
444 |
} |
|
445 |
} |
|
446 |
if (password.length == 0) { |
|
447 |
msg += password_empty + '\n'; |
|
448 |
} else if (password.length < 6) { |
|
449 |
msg += password_shorter + '\n'; |
|
450 |
} |
|
451 |
if (/ /.test(password) == true) { |
|
452 |
msg += passwd_balnk + '\n'; |
|
453 |
} |
|
454 |
if (confirm_password != password) { |
|
455 |
msg += confirm_password_invalid + '\n'; |
|
456 |
} |
|
457 |
if (checked_agreement != true) { |
|
458 |
msg += agreement + '\n'; |
|
459 |
} |
|
460 |
|
|
461 |
if (msn.length > 0 && (!Utils.isEmail(msn))) { |
|
462 |
msg += msn_invalid + '\n'; |
|
463 |
} |
|
464 |
|
|
465 |
if (qq.length > 0 && (!Utils.isNumber(qq))) { |
|
466 |
msg += qq_invalid + '\n'; |
|
467 |
} |
|
468 |
|
|
469 |
if (office_phone.length > 0) { |
|
470 |
var reg = /^[\d|\-|\s]+$/; |
|
471 |
if (!reg.test(office_phone)) { |
|
472 |
msg += office_phone_invalid + '\n'; |
|
473 |
} |
|
474 |
} |
|
475 |
if (home_phone.length > 0) { |
|
476 |
var reg = /^[\d|\-|\s]+$/; |
|
477 |
|
|
478 |
if (!reg.test(home_phone)) { |
|
479 |
msg += home_phone_invalid + '\n'; |
|
480 |
} |
|
481 |
} |
|
482 |
|
|
483 |
if ($("#mobile_code").size() > 0 && mobile_code.length == 0) { |
|
484 |
msg += msg_mobile_phone_code_blank + '\n'; |
|
485 |
} |
|
486 |
|
|
487 |
if ($("#captcha").size() > 0 && captcha.length == 0) { |
|
488 |
msg += msg_captcha_blank + '\n'; |
|
489 |
} |
|
490 |
|
|
491 |
// if (mobile_phone.length > 0) { |
|
492 |
// var reg = /^[\d|\-|\s]+$/; |
|
493 |
// if (!reg.test(mobile_phone)) { |
|
494 |
// msg += mobile_phone_invalid + '\n'; |
|
495 |
// } |
|
496 |
// } |
|
497 |
if (passwd_answer.length > 0 && sel_question == 0 || document.getElementById('passwd_quesetion') && passwd_answer.length == 0) { |
|
498 |
msg += no_select_question + '\n'; |
|
499 |
} |
|
500 |
|
|
501 |
for (var i = 4; i < frm.elements.length - 4; i++) // 从第五项开始循环检查是否为必填项 |
|
502 |
{ |
|
503 |
var needinput = document.getElementById(frm.elements[i].name + 'i') ? document.getElementById(frm.elements[i].name + 'i') : ''; |
|
504 |
|
|
505 |
if (needinput != '' && frm.elements[i].value.length == 0) { |
|
506 |
msg += '- ' + frm.elements[i].placeholder + "不能为空!" + '\n'; |
|
507 |
//msg += '- ' + needinput.innerHTML + msg_blank + '\n'; |
|
508 |
} |
|
509 |
} |
|
510 |
|
|
511 |
if (msg.length > 0) { |
|
512 |
alert(msg); |
|
513 |
return false; |
|
514 |
} else { |
|
515 |
return true; |
|
516 |
} |
|
517 |
} |
|
518 |
|
|
519 |
/** |
|
520 |
* 发送邮箱验证码 |
|
521 |
* |
|
522 |
* @param emailObj |
|
523 |
* 邮箱对象 |
|
524 |
* @param emailCodeObj |
|
525 |
* 邮箱验证码对象 |
|
526 |
* @param sendButton |
|
527 |
* 点击发送邮箱验证码的按钮对象,用于显示倒计时信息 |
|
528 |
*/ |
|
529 |
function sendEmailCode(emailObj, emailCodeObj, sendButton) { |
|
530 |
|
|
531 |
checkEmail(emailObj, function(result) { |
|
532 |
if (result) { |
|
533 |
// 发送邮件 |
|
534 |
// &XDEBUG_SESSION_START=ECLIPSE_DBGP |
|
535 |
var url = 'register.php?act=send_email_code'; |
|
536 |
$.post(url, { |
|
537 |
captcha: $("#captcha").size() > 0 ? $("#captcha").val() : "", |
|
538 |
email: emailObj.val() |
|
539 |
}, function(result) { |
|
540 |
if (result == 'ok') { |
|
541 |
// 倒计时 |
|
542 |
countdown(sendButton); |
|
543 |
$("#captcha_notice").html(""); |
|
544 |
$("#captcha_notice").css({color: '#093'}); |
|
545 |
} else { |
|
546 |
alert(result); |
|
547 |
} |
|
548 |
if($("#captcha").size() > 0){ |
|
549 |
$("#captcha_img").click(); |
|
550 |
} |
|
551 |
}, 'text'); |
|
552 |
} |
|
553 |
}); |
|
554 |
} |
|
555 |
|
|
556 |
/** |
|
557 |
* 发送手机验证码 |
|
558 |
* |
|
559 |
* @param mobileObj |
|
560 |
* 手机号对象 |
|
561 |
* @param mobileCodeObj |
|
562 |
* 短信验证码对象 |
|
563 |
* @param sendButton |
|
564 |
* 点击发送短信证码的按钮对象,用于显示倒计时信息 |
|
565 |
*/ |
|
566 |
function sendMobileCode(mobileObj, mobileCodeObj, sendButton) { |
|
567 |
checkMobilePhone(mobileObj, function(result) { |
|
568 |
if (result) { |
|
569 |
|
|
570 |
// 发送邮件 |
|
571 |
var url = 'register.php?act=send_mobile_code'; |
|
572 |
$.post(url, { |
|
573 |
XDEBUG_SESSION_START: 'ECLIPSE_DBGP', |
|
574 |
captcha: $("#captcha").size() > 0 ? $("#captcha").val() : "", |
|
575 |
mobile_phone: mobileObj.val() |
|
576 |
}, function(result) { |
|
577 |
if (result == 'ok') { |
|
578 |
// 倒计时 |
|
579 |
countdown(sendButton); |
|
580 |
$("#captcha_notice").html(""); |
|
581 |
$("#captcha_notice").css({color: '#093'}); |
|
582 |
} else { |
|
583 |
alert(result); |
|
584 |
} |
|
585 |
if($("#captcha").size() > 0){ |
|
586 |
$("#captcha_img").click(); |
|
587 |
} |
|
588 |
}, 'text'); |
|
589 |
} |
|
590 |
}); |
|
591 |
} |
|
592 |
|
|
593 |
/******************************************************************************* |
|
594 |
* 检测密码强度 |
|
595 |
* |
|
596 |
* @param string |
|
597 |
* pwd 密码 |
|
598 |
*/ |
|
599 |
function checkIntensity(pwd) { |
|
600 |
|
|
601 |
$("#pwd_notice").hide(); |
|
602 |
$("#pwd_intensity").show(); |
|
603 |
|
|
604 |
var Mcolor = "#FFF", Lcolor = "#FFF", Hcolor = "#FFF"; |
|
605 |
var m = 0; |
|
606 |
|
|
607 |
var Modes = 0; |
|
608 |
for (var i = 0; i < pwd.length; i++) { |
|
609 |
var charType = 0; |
|
610 |
var t = pwd.charCodeAt(i); |
|
611 |
if (t >= 48 && t <= 57) { |
|
612 |
charType = 1; |
|
613 |
} else if (t >= 65 && t <= 90) { |
|
614 |
charType = 2; |
|
615 |
} else if (t >= 97 && t <= 122) |
|
616 |
charType = 4; |
|
617 |
else |
|
618 |
charType = 4; |
|
619 |
Modes |= charType; |
|
620 |
} |
|
621 |
|
|
622 |
for (i = 0; i < 4; i++) { |
|
623 |
if (Modes & 1) |
|
624 |
m++; |
|
625 |
Modes >>>= 1; |
|
626 |
} |
|
627 |
|
|
628 |
if (pwd.length <= 4) { |
|
629 |
m = 1; |
|
630 |
} |
|
631 |
|
|
632 |
switch (m) { |
|
633 |
case 1: |
|
634 |
Lcolor = "2px solid red"; |
|
635 |
Mcolor = Hcolor = "2px solid #DADADA"; |
|
636 |
break; |
|
637 |
case 2: |
|
638 |
Mcolor = "2px solid #f90"; |
|
639 |
Lcolor = Hcolor = "2px solid #DADADA"; |
|
640 |
break; |
|
641 |
case 3: |
|
642 |
Hcolor = "2px solid #3c0"; |
|
643 |
Lcolor = Mcolor = "2px solid #DADADA"; |
|
644 |
break; |
|
645 |
case 4: |
|
646 |
Hcolor = "2px solid #3c0"; |
|
647 |
Lcolor = Mcolor = "2px solid #DADADA"; |
|
648 |
break; |
|
649 |
default: |
|
650 |
Hcolor = Mcolor = Lcolor = ""; |
|
651 |
break; |
|
652 |
} |
|
653 |
if (document.getElementById("pwd_lower")) { |
|
654 |
document.getElementById("pwd_lower").style.borderBottom = Lcolor; |
|
655 |
document.getElementById("pwd_middle").style.borderBottom = Mcolor; |
|
656 |
document.getElementById("pwd_high").style.borderBottom = Hcolor; |
|
657 |
} |
|
658 |
|
|
659 |
} |
|
660 |
|
|
661 |
var wait = 60; |
|
662 |
function countdown(obj, msg) { |
|
663 |
obj = $(obj); |
|
664 |
|
|
665 |
if (wait == 0) { |
|
666 |
obj.removeAttr("disabled"); |
|
667 |
obj.val(msg); |
|
668 |
wait = 60; |
|
669 |
} else { |
|
670 |
if (msg == undefined || msg == null) { |
|
671 |
msg = obj.val(); |
|
672 |
} |
|
673 |
obj.attr("disabled", "disabled"); |
|
674 |
obj.val(wait + "秒后重新获取"); |
|
675 |
wait--; |
|
676 |
setTimeout(function() { |
|
677 |
countdown(obj, msg) |
|
678 |
}, 1000) |
|
679 |
} |
|
680 |
} |
|
681 |
/* 代码增加2014-12-23 by _end */ |