You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
// 注册页面验证码点击刷新功能
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const captchaImg = document.querySelector('img[src="/captcha"]');
|
|
|
|
if (captchaImg) {
|
|
// 添加点击事件
|
|
captchaImg.addEventListener('click', function() {
|
|
// 添加时间戳防止缓存
|
|
const timestamp = new Date().getTime();
|
|
this.src = `/captcha?t=${timestamp}`;
|
|
|
|
// 添加点击反馈效果
|
|
this.style.transform = 'scale(0.95)';
|
|
setTimeout(() => {
|
|
this.style.transform = 'scale(1)';
|
|
}, 150);
|
|
});
|
|
|
|
// 添加鼠标样式提示
|
|
captchaImg.style.cursor = 'pointer';
|
|
captchaImg.title = '点击刷新验证码';
|
|
|
|
// 添加悬停效果
|
|
captchaImg.addEventListener('mouseenter', function() {
|
|
this.style.opacity = '0.8';
|
|
this.style.transition = 'opacity 0.2s ease';
|
|
});
|
|
|
|
captchaImg.addEventListener('mouseleave', function() {
|
|
this.style.opacity = '1';
|
|
});
|
|
}
|
|
|
|
// 表单验证
|
|
const registerForm = document.querySelector('form[action="/register"]');
|
|
if (registerForm) {
|
|
registerForm.addEventListener('submit', function(e) {
|
|
const password = document.getElementById('password');
|
|
const confirmPassword = document.getElementById('confirm_password');
|
|
|
|
if (password.value !== confirmPassword.value) {
|
|
e.preventDefault();
|
|
alert('两次输入的密码不一致,请重新输入');
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|